-
Notifications
You must be signed in to change notification settings - Fork 496
/
Copy pathcommon.test.ts
38 lines (28 loc) · 1.47 KB
/
common.test.ts
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
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {createElement, createTextChild, Overlay} from './common.js';
describe('common helper', () => {
it('can create DOM elements', () => {
assert.instanceOf(createElement('div', 'test'), HTMLDivElement);
});
it('exposes DOM manipulation methods on DOM elements', () => {
const wrapper = document.createElement('div');
assert.isTrue(Boolean(wrapper.createChild), 'createChild is available on DOM elements');
const child = wrapper.createChild('span', 'child');
assert.instanceOf(child, HTMLSpanElement, 'The right span element got created');
assert.strictEqual(child.className, 'child', 'The right className got set');
const textChild = createTextChild(wrapper, 'hello world');
assert.instanceOf(textChild, Text, 'The right text node got created');
assert.strictEqual(textChild.textContent, 'hello world', 'The right text content got set');
assert.isTrue(Boolean(wrapper.removeChildren), 'removeChildren is available on DOM elements');
wrapper.removeChildren();
assert.strictEqual(wrapper.childElementCount, 0, 'All children got removed');
});
it('sets the right platform', () => {
const overlay = new Overlay(window);
const platform = 'mac';
overlay.setPlatform(platform);
assert.isTrue(document.body.classList.contains(`platform-${platform}`));
});
});