1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/unit/webui/components/header.spec.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-12-01 20:04:01 +01:00
/**
* Header component
*/
import React from 'react';
import { shallow } from 'enzyme';
import Header from '../../../../src/webui/components/Header';
console.error = jest.fn();
2017-12-01 20:04:01 +01:00
describe('<Header /> component shallow', () => {
it('should give error for required props', () => {
shallow(<Header />);
expect(console.error).toHaveBeenCalled();
2017-12-01 20:04:01 +01:00
});
it('should load header component in login state', () => {
const props = {
username: 'verdaccio',
logo: 'logo.png',
scope: 'scope:',
handleLogout: jest.fn(),
toggleLoginModal: () => {}
}
const wrapper = shallow(<Header {...props} />);
wrapper.find('.header-button-logout').simulate('click');
expect(props.handleLogout).toHaveBeenCalled();
expect(wrapper.html()).toMatchSnapshot();
});
it('should load header component in logout state', () => {
const props = {
username: undefined,
logo: 'logo.png',
scope: 'scope:',
handleLogout: () => {},
toggleLoginModal: jest.fn()
}
const wrapper = shallow(<Header {...props} />);
wrapper.find('.header-button-login').simulate('click');
expect(props.toggleLoginModal).toHaveBeenCalled();
expect(wrapper.html()).toMatchSnapshot();
});
})