-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchecks.spec.js
67 lines (60 loc) · 1.62 KB
/
checks.spec.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
import {
isBoolean,
isFunction,
isNil,
isNode,
isObject,
isSvg,
isTemplate,
} from './checks.js'
import { expect } from 'chai'
describe('Checks', function () {
it('isFunction', () => {
expect(isFunction(() => {})).to.be.ok
expect(isFunction(null)).to.be.not.ok
})
it('isBoolean', () => {
expect(isBoolean(true)).to.be.ok
expect(isBoolean(false)).to.be.ok
expect(isBoolean(null)).to.be.not.ok
expect(isBoolean(0)).to.be.not.ok
expect(isBoolean(1)).to.be.not.ok
})
it('isNil', () => {
expect(isNil(true)).to.be.not.ok
expect(isNil(false)).to.be.not.ok
expect(isNil(null)).to.be.ok
expect(isNil(undefined)).to.be.ok
expect(isNil(0)).to.be.not.ok
expect(isNil(1)).to.be.not.ok
})
it('isNode', () => {
expect(isNode()).to.be.ok
})
it('isObject', () => {
expect(isObject({})).to.be.ok
expect(isObject(null)).to.be.not.ok
expect(isObject(Array)).to.be.not.ok
expect(isObject(() => {})).to.be.not.ok
expect(
isObject(
new (function () {
return {}
})(),
),
).to.be.ok
expect(isObject(new (function () {})())).to.be.not.ok
expect(isObject(undefined)).to.be.not.ok
})
it('isSvg', () => {
const div = document.createElement('div')
div.innerHTML = '<svg><g></g></svg><div></div>'
expect(isSvg(div.querySelector('svg'))).to.be.ok
expect(isSvg(div)).to.be.not.ok
expect(isSvg(div.querySelector('g'))).to.be.ok
})
it('isTemplate', () => {
expect(isTemplate(document.createElement('template'))).to.be.ok
expect(isTemplate(document.createElement('div'))).to.be.not.ok
})
})