mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
c3edcbfcf5
Includes: - Created css variables in JS. - Added JS helpers. - Replaced old sidebar by the "APP Bar" component from Material UI. - Replaced logo by the new version. - Added Avatar icon. - Added Info Icon. - Added Information Dialog, where the user can 'copy to the clipboard' the verdaccio commands. - Added Verdaccio website documentation link. - Added Drop Down Menu on the right side with a logout option
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
/**
|
|
* @prettier
|
|
* @flow
|
|
*/
|
|
|
|
import React from 'react';
|
|
import {shallow} from 'enzyme';
|
|
|
|
import CopyToClipBoard from '../../../../src/webui/components/CopyToClipBoard';
|
|
import {CopyIcon} from '../../../../src/webui/components/CopyToClipBoard/styles';
|
|
|
|
describe('<CopyToClipBoard /> component', () => {
|
|
let wrapper;
|
|
let props;
|
|
|
|
beforeEach(() => {
|
|
props = {
|
|
text: 'copy text',
|
|
};
|
|
wrapper = shallow(<CopyToClipBoard {...props} />);
|
|
});
|
|
|
|
test('render the component', () => {
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should call the DOM APIs for copy to clipboard utility', () => {
|
|
const event = {
|
|
preventDefault: jest.fn(),
|
|
};
|
|
|
|
global.getSelection = jest.fn(() => ({
|
|
removeAllRanges: () => {},
|
|
addRange: () => {},
|
|
}));
|
|
|
|
const {document, getSelection} = global;
|
|
|
|
wrapper.find(CopyIcon).simulate('click', event);
|
|
expect(event.preventDefault).toHaveBeenCalled();
|
|
expect(document.createRange).toHaveBeenCalled();
|
|
expect(getSelection).toHaveBeenCalled();
|
|
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
|
});
|
|
});
|