-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.js
56 lines (42 loc) · 1.74 KB
/
tests.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
'use strict';
function emulateClick() {
smartOutline._clickListener();
}
QUnit.module('Smart Outline Tests', function( hooks ) {
hooks.afterEach( function() {
smartOutline.destroy();
});
QUnit.test('smart outline should be available on window', function( assert ) {
assert.ok( window.hasOwnProperty('smartOutline'), 'Passed!' );
});
QUnit.test('Method call before init should throw error', function( assert ) {
assert.throws(smartOutline.isKeyboardUser, 'Passed!');
});
QUnit.test('Init should inject style element', function( assert ) {
var el = smartOutline.init();
assert.ok(el.innerHTML === '', 'Should be empty');
emulateClick();
assert.ok(el.innerHTML.indexOf(':focus') > -1, 'Should contain focus style');
});
QUnit.test('Custom domId option', function( assert ) {
var el = smartOutline.init({domId: 'customid'});
assert.ok(el.id === 'customid', 'Passed!');
});
QUnit.test('Custom nonce option', function( assert ) {
var el = smartOutline.init({nonce: 'random'});
assert.ok(el.nonce === 'random', 'Passed!');
});
QUnit.test('Custom hideFocusCSS option', function( assert ) {
var el = smartOutline.init({hideFocusCSS: 'bla'});
emulateClick();
assert.ok(el.innerHTML === 'bla', 'Passed!');
});
QUnit.test('Get options', function( assert ) {
var customOptions = {domId: 'test'};
smartOutline.init(customOptions);
var options = smartOutline.getOptions();
assert.ok(options.hasOwnProperty('domId'), 'Passed!');
assert.ok(options.hasOwnProperty('hideFocusCSS'), 'Passed!');
assert.ok(options.domId === customOptions.domId, 'Passed!');
});
});