1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-19 09:36:30 +07:00

chore: adds tests for action bar component (#88)

This commit is contained in:
Ayush Sharma
2019-07-07 19:30:01 +02:00
committed by GitHub
parent b6b0ecdb1e
commit f6e62d95bb
3 changed files with 60 additions and 9 deletions

View File

@@ -0,0 +1,48 @@
import React from 'react';
import { shallow } from 'enzyme';
describe('<ActionBar /> component', () => {
beforeEach(() => {
jest.resetModules();
});
test('should render the component in default state', () => {
const packageMeta = {
latest: {
homepage: 'https://verdaccio.tld',
bugs: {
url: 'https://verdaccio.tld/bugs',
},
dist: {
tarball: 'https://verdaccio.tld/download'
},
},
};
jest.doMock('../../pages/version/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const ActionBar = require('./ActionBar').default;
const wrapper = shallow(<ActionBar />);
expect(wrapper.html()).toMatchSnapshot();
});
test('when there is no action bar data', () => {
const packageMeta = {
latest: {},
};
jest.doMock('../../pages/version/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const ActionBar = require('./ActionBar').default;
const wrapper = shallow(<ActionBar />);
expect(wrapper.html()).toEqual('');
});
});