open-vault/ui/tests/integration/components/hover-copy-button-test.js
Matthew Irish 757afb4de9
UI - no jquery (#6768)
* add no-jquery rule and move event listeners to ember-concurrency tasks

* remove unnecessary onchange and handleKeyDown actions

* add element.closest polyfill and convert linked-block to use native dom apis

* update pretender, fetch, page-object, add optional-features, remove ember/jquery

* turn off jquery inclusion

* remove jQuery.isPlainObject usage

* violatedDirective isn't always formatted the same

* use fetch and the ember-fetch adapter mixin

* move to fetch and lowercase headers for pretender

* display non-ember-data errors

* use new async fn test style and lowercase headers in auth service test

* setContext is not necessary with the new style tests and ember-cli-page-object - it actually triggers jquery usage

* update ember-fetch, ember-cli-pretender

* wait for permissions check

* lowercase header name in auth test

* refactor transit tests to one test per key type

* simplify pollCluster helper

* stop flakey tests by prefering the native fetch

* avoid uncaught TransitionAborted error by navigating directly to unseal

* unset model on controller after unloading it because controllers are singletons

* update yarn.lock
2019-06-20 08:37:27 -05:00

36 lines
1.3 KiB
JavaScript

import { module, test, skip } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { create } from 'ember-cli-page-object';
import hbs from 'htmlbars-inline-precompile';
import copyButton from 'vault/tests/pages/components/hover-copy-button';
const component = create(copyButton);
module('Integration | Component | hover copy button', function(hooks) {
setupRenderingTest(hooks);
// ember-cli-clipboard helpers don't like the new style
skip('it shows success message in tooltip', async function(assert) {
this.set('copyValue', 'foo');
await render(
hbs`<div class="has-copy-button" tabindex="-1">
<HoverCopyButton @copyValue={{copyValue}} />
</div>`
);
await component.focusContainer();
assert.ok(component.buttonIsVisible);
await component.mouseEnter();
assert.equal(component.tooltipText, 'Copy', 'shows copy');
await component.click();
assert.equal(component.tooltipText, 'Copied!', 'shows success message');
});
test('it has the correct class when alwaysShow is true', async function(assert) {
this.set('copyValue', 'foo');
await render(hbs`{{hover-copy-button alwaysShow=true copyValue=copyValue}}`);
assert.ok(component.buttonIsVisible);
assert.ok(component.wrapperClass.includes('hover-copy-button-static'));
});
});