HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/cwd/home/arjun/projects/buyercall/node_modules/clipboard/test/common/command.js
import select from 'select';
import command from '../../src/common/command';

describe('#command', () => {
  before(() => {
    global.stub = sinon.stub(document, 'execCommand');
    global.input = document.createElement('input');
    global.input.setAttribute('id', 'input');
    global.input.setAttribute('value', 'abc');
    document.body.appendChild(global.input);
  });

  after(() => {
    global.stub.restore();
    document.body.innerHTML = '';
  });

  it('should execute cut', (done) => {
    global.stub.returns(true);
    select(document.querySelector('#input'));

    assert.isTrue(command('cut'));
    done();
  });

  it('should execute copy', (done) => {
    global.stub.returns(true);
    select(document.querySelector('#input'));

    assert.isTrue(command('copy'));
    done();
  });

  it('should not execute copy', (done) => {
    global.stub.returns(false);
    select(document.querySelector('#input'));

    assert.isFalse(command('copy'));
    done();
  });

  it('should not execute cut', (done) => {
    global.stub.returns(false);
    select(document.querySelector('#input'));

    assert.isFalse(command('cut'));
    done();
  });
});