@domql/element 2.3.46 → 2.3.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/test/create.test.js +0 -136
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.70",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
"@domql/set": "latest",
|
|
11
11
|
"@domql/update": "latest"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "c2fa4c40d134093b837eafc1c4374561032281bf",
|
|
14
14
|
"source": "index.js"
|
|
15
15
|
}
|
package/test/create.test.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { tree } from '@domql/tree'
|
|
4
|
-
import { create } from '../create'
|
|
5
|
-
|
|
6
|
-
describe('Should create DOMQL element', () => {
|
|
7
|
-
const dom = create({})
|
|
8
|
-
|
|
9
|
-
test('should create EMPTY element', () => {
|
|
10
|
-
expect(dom.key).toBe(1)
|
|
11
|
-
expect(dom.tag).toBe('div')
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
test('should create REF', () => {
|
|
15
|
-
const { ref } = dom
|
|
16
|
-
expect(ref.tag).toBe('div')
|
|
17
|
-
expect(ref.parent).toEqual(tree)
|
|
18
|
-
expect(ref.state).toEqual({})
|
|
19
|
-
expect(ref.props).toEqual({})
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
describe('Should create DOMQL element from PRIMITIVES', () => {
|
|
24
|
-
const ref = {
|
|
25
|
-
tag: 'div',
|
|
26
|
-
parent: tree,
|
|
27
|
-
state: {},
|
|
28
|
-
props: {}
|
|
29
|
-
}
|
|
30
|
-
test('should create element from Int', () => {
|
|
31
|
-
const number = create(123)
|
|
32
|
-
expect(number).toEqual({
|
|
33
|
-
key: 6,
|
|
34
|
-
tag: 'div',
|
|
35
|
-
text: 123,
|
|
36
|
-
ref
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
test('should create element from String', () => {
|
|
40
|
-
const string = create('test')
|
|
41
|
-
expect(string).toEqual({
|
|
42
|
-
key: 7,
|
|
43
|
-
tag: 'div',
|
|
44
|
-
text: 'test',
|
|
45
|
-
ref
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
describe('Should create NESTED DOMQL element', () => {
|
|
51
|
-
const dom = create({
|
|
52
|
-
test: 123,
|
|
53
|
-
test2: 'test2',
|
|
54
|
-
test3: { text: 'test3' }
|
|
55
|
-
})
|
|
56
|
-
const ref = {
|
|
57
|
-
tag: 'div',
|
|
58
|
-
parent: tree,
|
|
59
|
-
state: {},
|
|
60
|
-
props: {}
|
|
61
|
-
}
|
|
62
|
-
test('element must have children', () => {
|
|
63
|
-
const { children, childrenKeys } = dom.ref
|
|
64
|
-
expect(children).toEqual(expect.any(Array))
|
|
65
|
-
expect(childrenKeys).toEqual(expect.any(Array))
|
|
66
|
-
expect(childrenKeys).toHaveLength(3)
|
|
67
|
-
expect(childrenKeys).toEqual(['test', 'test2', 'test3'])
|
|
68
|
-
})
|
|
69
|
-
test('should structure proper children', () => {
|
|
70
|
-
const { children } = dom.ref
|
|
71
|
-
expect(children[0]).toEqual({
|
|
72
|
-
key: 3,
|
|
73
|
-
tag: 'div',
|
|
74
|
-
text: 123,
|
|
75
|
-
ref
|
|
76
|
-
})
|
|
77
|
-
expect(children[1]).toEqual({
|
|
78
|
-
key: 4,
|
|
79
|
-
tag: 'div',
|
|
80
|
-
text: 'test2',
|
|
81
|
-
ref
|
|
82
|
-
})
|
|
83
|
-
expect(children[2]).toEqual({
|
|
84
|
-
key: 5,
|
|
85
|
-
tag: 'div',
|
|
86
|
-
text: 'test3',
|
|
87
|
-
ref
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
// test('should create valid DOM node', () => {
|
|
93
|
-
// expect(dom.node).toBeInstanceOf(window.HTMLDivElement)
|
|
94
|
-
// })
|
|
95
|
-
|
|
96
|
-
// test('must be able to create valid PATH', () => {
|
|
97
|
-
// expect(dom.path).toStrictEqual([dom.key])
|
|
98
|
-
// })
|
|
99
|
-
|
|
100
|
-
// test('if it HAS a NODE, don\'t recreate', () => {
|
|
101
|
-
// const node = document.createElement('div')
|
|
102
|
-
// const dom2 = create({ node })
|
|
103
|
-
// expect(dom2.node.parentElement).toBe(document.body)
|
|
104
|
-
// })
|
|
105
|
-
|
|
106
|
-
// test('create with number', () => {
|
|
107
|
-
// const numb = create(0)
|
|
108
|
-
// expect(numb.text).toBe(0)
|
|
109
|
-
// expect(numb.tag).toBe('string')
|
|
110
|
-
// expect(numb.node.nodeType).toBe(3) // #text
|
|
111
|
-
// })
|
|
112
|
-
|
|
113
|
-
// test('create with string', () => {
|
|
114
|
-
// const str = create('hello')
|
|
115
|
-
// expect(str.text).toBe('hello')
|
|
116
|
-
// expect(str.tag).toBe('string')
|
|
117
|
-
// expect(str.node.nodeType).toBe(3) // #text
|
|
118
|
-
// })
|
|
119
|
-
|
|
120
|
-
// test('creating conditions', () => {
|
|
121
|
-
// const element = create({
|
|
122
|
-
// data: { visible: true },
|
|
123
|
-
// if: element => element.data.visible
|
|
124
|
-
// })
|
|
125
|
-
// expect(element.tag).toBe('div')
|
|
126
|
-
// })
|
|
127
|
-
|
|
128
|
-
// test('creating nesting', () => {
|
|
129
|
-
// const element = create({
|
|
130
|
-
// header: {
|
|
131
|
-
// h1: {}
|
|
132
|
-
// }
|
|
133
|
-
// })
|
|
134
|
-
// expect(element.header.tag).toBe('header')
|
|
135
|
-
// expect(element.header.h1.tag).toBe('h1')
|
|
136
|
-
// })
|