-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathau-main-container-test.gts
108 lines (88 loc) · 3.09 KB
/
au-main-container-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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import AuMainContainer from '@appuniversum/ember-appuniversum/components/au-main-container';
import { render, settled } from '@ember/test-helpers';
import { tracked } from '@glimmer/tracking';
import { setupRenderingTest } from 'ember-qunit';
import { module, test } from 'qunit';
const MAIN_CONTAINER = {
CONTAINER: '[data-test-main-container]',
SIDEBAR: '[data-test-main-container-sidebar]',
CONTENT: '[data-test-main-container-content]',
};
module('Integration | Component | au-main-container', function (hooks) {
setupRenderingTest(hooks);
test("it's possible to pass extra html attributes", async function (assert) {
await render(
<template>
<AuMainContainer data-test-main-container class="test" />
</template>,
);
assert.dom(MAIN_CONTAINER.CONTAINER).exists().hasClass('test');
});
test('it yields a sidebar component that is only visible when it has block contents', async function (assert) {
await render(
<template>
<AuMainContainer as |main|>
<main.sidebar data-test-main-container-sidebar>Sidebar contents</main.sidebar>
</AuMainContainer>
</template>,
);
assert.dom(MAIN_CONTAINER.SIDEBAR).exists().hasText('Sidebar contents');
await render(
<template>
<AuMainContainer as |main|>
<main.sidebar data-test-main-container-sidebar />
</AuMainContainer>
</template>,
);
assert.dom(MAIN_CONTAINER.SIDEBAR).doesNotExist();
await render(<template><AuMainContainer /></template>);
assert.dom(MAIN_CONTAINER.SIDEBAR).doesNotExist();
});
test('it yields a content component that is only visible when it has block contents', async function (assert) {
await render(
<template>
<AuMainContainer as |main|>
<main.content data-test-main-container-content>Main contents</main.content>
</AuMainContainer>
</template>,
);
assert.dom(MAIN_CONTAINER.CONTENT).exists().hasText('Main contents');
await render(
<template>
<AuMainContainer as |main|>
<main.content data-test-main-container-content />
</AuMainContainer>
</template>,
);
assert.dom(MAIN_CONTAINER.CONTENT).doesNotExist();
});
test("it's possible to force the content to scroll if its larger than its parent", async function (assert) {
class TestState {
@tracked shouldScroll: boolean = false;
}
const state = new TestState();
await render(
<template>
<AuMainContainer as |main|>
<main.content
@scroll={{state.shouldScroll}}
data-test-main-container-content
>Main contents</main.content>
</AuMainContainer>
</template>,
);
const containerElement = document.querySelector(
MAIN_CONTAINER.CONTENT,
) as HTMLElement;
assert.notStrictEqual(
getComputedStyle(containerElement).getPropertyValue('overflow-y'),
'auto',
);
state.shouldScroll = true;
await settled();
assert.strictEqual(
getComputedStyle(containerElement).getPropertyValue('overflow-y'),
'auto',
);
});
});