-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathau-link-external-test.gts
64 lines (53 loc) · 1.61 KB
/
au-link-external-test.gts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import AuLinkExternal from '@appuniversum/ember-appuniversum/components/au-link-external';
import { tracked } from '@glimmer/tracking';
import { settled } from '@ember/test-helpers';
module('Integration | Component | au-link-external', function (hooks) {
setupRenderingTest(hooks);
test('it accepts block content and extra attributes', async function (assert) {
await render(
<template>
<AuLinkExternal data-test-link-external>
template block text
</AuLinkExternal>
</template>,
);
assert.dom('[data-test-link-external]').hasText('template block text');
});
test('it accepts a `@newTab` argument', async function (assert) {
await render(
<template>
<AuLinkExternal data-test-link-external>
template block text
</AuLinkExternal>
</template>,
);
assert
.dom('[data-test-link-external]')
.hasAttribute('target')
.hasAttribute('rel');
const state = new TestState();
await render(
<template>
<AuLinkExternal @newTab={{state.newTab}} data-test-link-external>
template block text
</AuLinkExternal>
</template>,
);
assert
.dom('[data-test-link-external]')
.hasNoAttribute('target')
.hasNoAttribute('rel');
state.newTab = true;
await settled();
assert
.dom('[data-test-link-external]')
.hasAttribute('target')
.hasAttribute('rel');
});
});
class TestState {
@tracked newTab = false;
}