Repository URL to install this package:
|
Version:
8.0.0 ▾
|
"use strict";
var _copyToClipboard = _interopRequireDefault(require("./copyToClipboard"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
beforeAll(function () {
document.createRange = function () {};
document.execCommand = function () {};
document.getSelection = function () {
return {
getRangeAt: function getRangeAt() {}
};
};
});
test('checking if text is copied', function () {
var spyFunc = jest.fn();
var spyCreateRange = jest.fn(function () {
var obj = {};
obj.selectNodeContents = function () {};
return obj;
});
Object.defineProperty(global.document, 'execCommand', {
value: spyFunc
});
Object.defineProperty(global.document, 'createRange', {
value: spyCreateRange
});
Object.defineProperty(window, 'getSelection', {
value: function value() {
return {
removeAllRanges: function removeAllRanges() {},
addRange: function addRange() {}
};
}
});
var parent = document.createElement('div');
(0, _copyToClipboard["default"])('test url', parent);
expect(spyFunc).toHaveBeenCalledWith('copy');
});