From 22acd4894d9c64c496837c9c875bb16981cdb9a2 Mon Sep 17 00:00:00 2001 From: "Kita Pairojtanachai (Chris)" Date: Thu, 10 Feb 2022 12:10:02 -0500 Subject: [PATCH] migrate certain files in __mocks__/ (#45071) * change ref from styleMock.js to .ts * change ref from fileMock.js to .ts --- client/src/__mocks__/fileMock.js | 1 - client/src/__mocks__/fileMock.ts | 1 + client/src/__mocks__/gatsby-link.js | 8 -------- client/src/__mocks__/gatsby-link.ts | 13 +++++++++++++ client/src/__mocks__/styleMock.js | 1 - client/src/__mocks__/styleMock.ts | 1 + jest.config.js | 4 ++-- 7 files changed, 17 insertions(+), 12 deletions(-) delete mode 100644 client/src/__mocks__/fileMock.js create mode 100644 client/src/__mocks__/fileMock.ts delete mode 100644 client/src/__mocks__/gatsby-link.js create mode 100644 client/src/__mocks__/gatsby-link.ts delete mode 100644 client/src/__mocks__/styleMock.js create mode 100644 client/src/__mocks__/styleMock.ts diff --git a/client/src/__mocks__/fileMock.js b/client/src/__mocks__/fileMock.js deleted file mode 100644 index f053ebf797..0000000000 --- a/client/src/__mocks__/fileMock.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {}; diff --git a/client/src/__mocks__/fileMock.ts b/client/src/__mocks__/fileMock.ts new file mode 100644 index 0000000000..ff8b4c5632 --- /dev/null +++ b/client/src/__mocks__/fileMock.ts @@ -0,0 +1 @@ +export default {}; diff --git a/client/src/__mocks__/gatsby-link.js b/client/src/__mocks__/gatsby-link.js deleted file mode 100644 index 4dcca4213e..0000000000 --- a/client/src/__mocks__/gatsby-link.js +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable */ -import React from 'react'; - -const mockComponent = name => props => - React.createElement(name, props, props.children); - -export const navigateTo = () => {}; -export default mockComponent('MockedLink'); diff --git a/client/src/__mocks__/gatsby-link.ts b/client/src/__mocks__/gatsby-link.ts new file mode 100644 index 0000000000..c6e13b0505 --- /dev/null +++ b/client/src/__mocks__/gatsby-link.ts @@ -0,0 +1,13 @@ +/* eslint-disable */ +import React from 'react'; + +const mockComponent = + (name: string) => + ( + props: React.InputHTMLAttributes & + React.ClassAttributes + ) => + React.createElement(name, props, props.children); + +export const navigateTo = () => {}; +export default mockComponent('MockedLink'); diff --git a/client/src/__mocks__/styleMock.js b/client/src/__mocks__/styleMock.js deleted file mode 100644 index f053ebf797..0000000000 --- a/client/src/__mocks__/styleMock.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {}; diff --git a/client/src/__mocks__/styleMock.ts b/client/src/__mocks__/styleMock.ts new file mode 100644 index 0000000000..ff8b4c5632 --- /dev/null +++ b/client/src/__mocks__/styleMock.ts @@ -0,0 +1 @@ +export default {}; diff --git a/jest.config.js b/jest.config.js index 1ac15b043b..20a49f14a3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,11 +2,11 @@ module.exports = { testPathIgnorePatterns: ['/node_modules/'], moduleNameMapper: { '\\.(jpg|jpeg|png|svg|woff|woff2)$': - '/client/src/__mocks__/fileMock.js', + '/client/src/__mocks__/fileMock.ts', // Plain CSS - match css files that don't end with // '.module.css' https://regex101.com/r/VzwrKH/4 '^(?!.*\\.module\\.css$).*\\.css$': - '/client/src/__mocks__/styleMock.js', + '/client/src/__mocks__/styleMock.ts', // CSS Modules - match files that end with 'module.css' '\\.module\\.css$': 'identity-obj-proxy', '^lodash-es$': 'lodash'