-
Notifications
You must be signed in to change notification settings - Fork 10
/
resizing-test.js
76 lines (62 loc) · 1.94 KB
/
resizing-test.js
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
import { module, test, skip } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import waitForWidth from 'dummy/tests/helpers/wait-for-width';
const HEIGHT = 500;
const isHeadlessChrome = /HeadlessChrome/.test(window.navigator.userAgent);
module('Acceptance | resizing', function (hooks) {
setupApplicationTest(hooks);
hooks.beforeEach(function () {
this.popup = window.open('/index.html', 'resizable', `resizable=yes`);
this.popup.addEventListener('load', (event) => {
event.currentTarget.DummyApplication.visit('/');
});
});
hooks.afterEach(function () {
this.popup.close();
});
if (isHeadlessChrome) {
skip('Skipping Chrome resizing integration test');
return;
}
test('visiting /resizing', async function (assert) {
this.popup.resizeTo(200, HEIGHT);
await waitForWidth(this.popup, 200);
assert.deepEqual(
serializeMediaQueries(this.popup.document),
{
isSmallAndUp: 'false',
isMediumAndUp: 'false',
isLargeAndUp: 'false',
isExtraLargeAndUp: 'false',
isExtraSmallAndDown: 'true',
isSmallAndDown: 'true',
isMediumAndDown: 'true',
isLargeAndDown: 'true',
},
'Initial values are correct'
);
this.popup.resizeTo(900, HEIGHT);
await waitForWidth(this.popup, 900);
assert.deepEqual(
serializeMediaQueries(this.popup.document),
{
isSmallAndUp: 'true',
isMediumAndUp: 'true',
isLargeAndUp: 'false',
isExtraLargeAndUp: 'false',
isExtraSmallAndDown: 'false',
isSmallAndDown: 'false',
isMediumAndDown: 'true',
isLargeAndDown: 'true',
},
'Updated values are correct'
);
});
function serializeMediaQueries(doc) {
let data = {};
doc.querySelectorAll('#media-queries dt').forEach(function (dt) {
data[dt.textContent.trim()] = dt.nextElementSibling.textContent.trim();
});
return data;
}
});