mirror of
https://github.com/SomboChea/ui
synced 2024-05-19 09:51:36 +07:00
111f0c50e5
* chore: updated emotion dependency * feat: introduced theme * refactor: updated emotion styles * fix: fixed emotion error * fix: fixed tests * chore: add missing types Co-Authored-By: Thomas Klein <tmkn@users.noreply.github.com>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
|
|
import { mount } from '../../utils/test-enzyme';
|
|
import { DetailContext } from '../../pages/Version';
|
|
import { PackageMetaInterface } from '../../../types/packageMeta';
|
|
|
|
import Engine from './Engines';
|
|
|
|
jest.mock('./img/node.png', () => '');
|
|
jest.mock('../Install/img/npm.svg', () => '');
|
|
|
|
const mockPackageMeta = (engines?: PackageMetaInterface['latest']['engines']): PackageMetaInterface => ({
|
|
latest: {
|
|
name: 'verdaccio',
|
|
version: '0.0.0',
|
|
dist: {
|
|
fileCount: 1,
|
|
unpackedSize: 1,
|
|
},
|
|
...(engines && { engines }),
|
|
},
|
|
_uplinks: {},
|
|
});
|
|
|
|
describe('<Engines /> component', () => {
|
|
test('should render the component in default state', () => {
|
|
const packageMeta = mockPackageMeta({
|
|
node: '>= 0.1.98',
|
|
npm: '>3',
|
|
});
|
|
|
|
const wrapper = mount(
|
|
<DetailContext.Provider value={{ packageMeta }}>
|
|
<Engine />
|
|
</DetailContext.Provider>
|
|
);
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should render the component when there is no engine key in package meta', () => {
|
|
const packageMeta = mockPackageMeta();
|
|
|
|
const wrapper = mount(
|
|
<DetailContext.Provider value={{ packageMeta }}>
|
|
<Engine />
|
|
</DetailContext.Provider>
|
|
);
|
|
expect(wrapper.html()).toBeNull();
|
|
});
|
|
|
|
test('should render the component when there is no keys in engine in package meta', () => {
|
|
const packageMeta = mockPackageMeta({});
|
|
|
|
const wrapper = mount(
|
|
<DetailContext.Provider value={{ packageMeta }}>
|
|
<Engine />
|
|
</DetailContext.Provider>
|
|
);
|
|
expect(wrapper.html()).toBeNull();
|
|
});
|
|
});
|