mirror of
https://github.com/SomboChea/ui
synced 2026-01-18 09:06:14 +07:00
chore: enable optional chaining and nullish (#306)
This commit is contained in:
committed by
Priscila Oliveira
parent
58cf730b98
commit
0a48906fc8
@@ -3,6 +3,7 @@ import { ReactWrapper } from 'enzyme';
|
||||
|
||||
import { mount } from '../utils/test-enzyme';
|
||||
import storage from '../utils/storage';
|
||||
// eslint-disable-next-line jest/no-mocks-import
|
||||
import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__/token';
|
||||
|
||||
import App from './App';
|
||||
@@ -31,6 +32,7 @@ jest.mock('../utils/storage', () => {
|
||||
});
|
||||
|
||||
jest.mock('../utils/api', () => ({
|
||||
// eslint-disable-next-line jest/no-mocks-import
|
||||
request: require('../../jest/unit/components/__mocks__/api').default.request,
|
||||
}));
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import node from './img/node.png';
|
||||
const Engine: React.FC = () => {
|
||||
const { packageMeta } = useContext(DetailContext);
|
||||
|
||||
const engines = packageMeta && packageMeta.latest && packageMeta.latest.engines;
|
||||
const engines = packageMeta?.latest?.engines;
|
||||
|
||||
if (!engines || (!engines.node && !engines.npm)) {
|
||||
return null;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// eslint-disable-next-line jest/no-mocks-import
|
||||
import {
|
||||
generateTokenWithTimeRange,
|
||||
generateTokenWithExpirationAsString,
|
||||
@@ -11,6 +12,7 @@ import { isTokenExpire, makeLogin } from './login';
|
||||
console.error = jest.fn();
|
||||
|
||||
jest.mock('./api', () => ({
|
||||
// eslint-disable-next-line jest/no-mocks-import
|
||||
request: require('../../jest/unit/components/__mocks__/api').default.request,
|
||||
}));
|
||||
|
||||
@@ -40,11 +42,8 @@ describe('isTokenExpire', (): void => {
|
||||
|
||||
test('isTokenExpire - token is not a valid json token', (): void => {
|
||||
const token = generateInvalidToken();
|
||||
const result = [
|
||||
'Invalid token:',
|
||||
new SyntaxError('Unexpected token i in JSON at position 0'),
|
||||
'xxxxxx.aW52YWxpZHRva2Vu.xxxxxx',
|
||||
];
|
||||
const errorToken = new SyntaxError('Unexpected token i in JSON at position 0');
|
||||
const result = ['Invalid token:', errorToken, 'xxxxxx.aW52YWxpZHRva2Vu.xxxxxx'];
|
||||
expect(isTokenExpire(token)).toBeTruthy();
|
||||
expect(console.error).toHaveBeenCalledWith(...result);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user