Skip to content

Commit

Permalink
Change arrow functions to named functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Feb 1, 2023
1 parent f640b35 commit f320331
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/shared/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const isPage = PropTypes.shape({
render: PropTypes.func.isRequired,
});

export const isPageIndex = (props, propName, componentName) => {
export function isPageIndex(props, propName, componentName) {
const { [propName]: pageIndex, pageNumber, pdf } = props;

if (!isDefined(pdf)) {
Expand Down Expand Up @@ -83,9 +83,9 @@ export const isPageIndex = (props, propName, componentName) => {

// Everything is fine
return null;
};
}

export const isPageNumber = (props, propName, componentName) => {
export function isPageNumber(props, propName, componentName) {
const { [propName]: pageNumber, pageIndex, pdf } = props;

if (!isDefined(pdf)) {
Expand Down Expand Up @@ -116,7 +116,7 @@ export const isPageNumber = (props, propName, componentName) => {

// Everything is fine
return null;
};
}

export const isPdf = PropTypes.oneOfType([
PropTypes.shape({
Expand Down
16 changes: 8 additions & 8 deletions test-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env jest */
const fs = require('fs');

export const makeAsyncCallback = (callbackValue) => {
export function makeAsyncCallback(callbackValue) {
let promiseResolve;
const promise = new Promise((resolve) => {
promiseResolve = resolve;
Expand All @@ -13,9 +13,9 @@ export const makeAsyncCallback = (callbackValue) => {
);

return { promise, func };
};
}

export const loadPDF = (path) => {
export function loadPDF(path) {
const raw = fs.readFileSync(path);
const arrayBuffer = raw.buffer;

Expand All @@ -35,16 +35,16 @@ export const loadPDF = (path) => {
return new File([arrayBuffer], { type: 'application/pdf' });
},
};
};
}

export const muteConsole = () => {
export function muteConsole() {
jest.spyOn(global.console, 'log').mockImplementation(() => {});
jest.spyOn(global.console, 'error').mockImplementation(() => {});
jest.spyOn(global.console, 'warn').mockImplementation(() => {});
};
}

export const restoreConsole = () => {
export function restoreConsole() {
global.console.log.mockRestore();
global.console.error.mockRestore();
global.console.warn.mockRestore();
};
}
5 changes: 3 additions & 2 deletions test/Test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const options = {
standardFontDataUrl: 'standard_fonts/',
};

export const readAsDataURL = (file) =>
new Promise((resolve, reject) => {
export function readAsDataURL(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();

reader.onload = () => resolve(reader.result);
Expand All @@ -45,6 +45,7 @@ export const readAsDataURL = (file) =>

return null;
});
}

/* eslint-disable no-console */

Expand Down

0 comments on commit f320331

Please sign in to comment.