chore(client): Typescript migration of __mocks__/gatsby.js (#47334)

* chore(client): Typescript migration of __mocks__/gatsby.js

* chore(client): Typescript migration of __mocks__/gatsby.js
pull/47391/head
SadmanSyfe 2022-08-27 04:27:08 +06:00 committed by GitHub
parent 6cde7ce90f
commit ec3d6deb35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 16 deletions

View File

@ -1,9 +1,9 @@
/* eslint-disable no-unused-vars */
const React = require('react');
import React from 'react';
import { GatsbyLinkProps } from 'gatsby';
const gatsby: NodeModule = jest.requireActual('gatsby');
const gatsby = jest.requireActual('gatsby');
const envData = require('../../../config/env.json');
import envData from '../../../config/env.json';
const { clientLocale } = envData;
@ -13,23 +13,13 @@ module.exports = {
graphql: jest.fn(),
Link: jest.fn().mockImplementation(
// these props are invalid for an `a` tag
({
activeClassName,
activeStyle,
getProps,
innerRef,
partiallyActive,
ref,
replace,
to,
...rest
}) =>
({ to, ...rest }: GatsbyLinkProps<undefined | boolean>) =>
React.createElement('a', {
...rest,
href: to
})
),
withPrefix: jest.fn().mockImplementation(path => {
withPrefix: jest.fn().mockImplementation((path: string) => {
const pathPrefix =
clientLocale === 'english' || clientLocale === 'chinese'
? ''