/
helpers.js
30 lines (28 loc) 路 1.12 KB
/
helpers.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
import {getDocument, checkContainerType} from '../helpers'
test('returns global document if exists', () => {
expect(getDocument()).toBe(document)
})
describe('query container validation throws when validation fails', () => {
test('undefined as container', () => {
expect(() =>
checkContainerType(undefined),
).toThrowErrorMatchingInlineSnapshot(
`"Expected container to be an Element, a Document or a DocumentFragment but got undefined."`,
)
})
test('null as container', () => {
expect(() => checkContainerType(null)).toThrowErrorMatchingInlineSnapshot(
`"Expected container to be an Element, a Document or a DocumentFragment but got null."`,
)
})
test('array as container', () => {
expect(() => checkContainerType([])).toThrowErrorMatchingInlineSnapshot(
`"Expected container to be an Element, a Document or a DocumentFragment but got Array."`,
)
})
test('object as container', () => {
expect(() => checkContainerType({})).toThrowErrorMatchingInlineSnapshot(
`"Expected container to be an Element, a Document or a DocumentFragment but got Object."`,
)
})
})