github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/tests/integration/components/copy-button-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupRenderingTest } from 'ember-qunit'; 3 import { click, render } from '@ember/test-helpers'; 4 import hbs from 'htmlbars-inline-precompile'; 5 6 import sinon from 'sinon'; 7 8 import { triggerCopyError, triggerCopySuccess } from 'ember-cli-clipboard/test-support'; 9 10 module('Integration | Component | copy-button', function(hooks) { 11 setupRenderingTest(hooks); 12 13 test('it shows the copy icon by default', async function(assert) { 14 await render(hbs`{{copy-button class='copy-button'}}`); 15 16 assert.dom('.copy-button .icon-is-copy-action').exists(); 17 }); 18 19 test('it shows the success icon on success and resets afterward', async function(assert) { 20 const clock = sinon.useFakeTimers(); 21 22 await render(hbs`{{copy-button class='copy-button'}}`); 23 24 await click('.copy-button button'); 25 await triggerCopySuccess('.copy-button button'); 26 27 assert.dom('.copy-button .icon-is-copy-success').exists(); 28 29 clock.runAll(); 30 31 assert.dom('.copy-button .icon-is-copy-success').doesNotExist(); 32 assert.dom('.copy-button .icon-is-copy-action').exists(); 33 34 clock.restore(); 35 }); 36 37 test('it shows the error icon on error', async function(assert) { 38 await render(hbs`{{copy-button class='copy-button'}}`); 39 40 await click('.copy-button button'); 41 await triggerCopyError('.copy-button button'); 42 43 assert.dom('.copy-button .icon-is-alert-triangle').exists(); 44 }); 45 });