Files
30-seconds-of-code/test/copyToClipboard.test.js
Angelos Chalaris 9ef51d3586 Cleanup
2018-11-10 14:48:56 +02:00

32 lines
852 B
JavaScript

const expect = require('expect');
const {copyToClipboard} = require('./_30s.js');
test('copyToClipboard is a Function', () => {
expect(copyToClipboard).toBeInstanceOf(Function);
});
test('copyToClipboard does not throw errors', () => {
document.getSelection = function() {
return {
rangeCount: 0,
removeAllRanges() { return; },
addRange(x) { return x; }
};
};
document.execCommand = function(x) { return x; };
expect(copyToClipboard('hi')).toBe(undefined);
});
test('copyToClipboard does not throw errors', () => {
document.getSelection = function() {
return {
rangeCount: 1,
getRangeAt(x) { return x + 1; },
removeAllRanges() { return; },
addRange(x) { return x; }
};
};
document.execCommand = function(x) { return x; };
expect(copyToClipboard('hi')).toBe(undefined);
});