literaljs 7.0.2 → 8.0.1

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.
@@ -1,195 +0,0 @@
1
- import { render, component, h } from '../src';
2
-
3
- describe('Render Tests', () => {
4
- beforeAll((done) => {
5
- done();
6
- });
7
-
8
- test('Render Mounts Properly', () => {
9
- document.body.innerHTML = '<div id="root"></div>';
10
-
11
- const Comp = component({
12
- render() {
13
- return h('div', { id: 'container' }, 'Hello World');
14
- }
15
- });
16
-
17
- render(Comp, 'root', {});
18
-
19
- const containerHTML = document.getElementById('container').innerHTML;
20
-
21
- expect(containerHTML).toEqual('Hello World');
22
- });
23
-
24
- test('Render Global Store Properly', () => {
25
- document.body.innerHTML = '<div id="root"></div>';
26
-
27
- const Comp = component({
28
- render() {
29
- return h(
30
- 'span',
31
- { class: 'container', id: 'count' },
32
- this.getStore().count
33
- );
34
- }
35
- });
36
-
37
- render(Comp, 'root', { count: 1 });
38
-
39
- const count = document.getElementById('count').innerHTML;
40
-
41
- expect(count).toEqual('1');
42
- });
43
-
44
- test('Render Multiple Components With State Properly', () => {
45
- document.body.innerHTML = '<div id="root"></div>';
46
-
47
- const Comp2 = component({
48
- state: { count: 1 },
49
- render() {
50
- return h('span', { id: 'count' }, this.getState().count);
51
- }
52
- });
53
-
54
- const Comp = component({
55
- render() {
56
- return h('div', { class: 'container' }, Comp2());
57
- }
58
- });
59
-
60
- render(Comp, 'root', {});
61
-
62
- const count = document.getElementById('count').innerHTML;
63
-
64
- expect(count).toEqual('1');
65
- });
66
-
67
- test('Renders True Markup Booleans Properly', () => {
68
- document.body.innerHTML = '<div id="root"></div>';
69
-
70
- const Comp = component({
71
- state: { show: true },
72
- render() {
73
- return h('div', { class: 'container' }, [
74
- this.getState().show && h('span', { id: 'hello' }, 'Hello World')
75
- ]);
76
- }
77
- });
78
-
79
- render(Comp, 'root', {});
80
-
81
- const containerHTML = document.getElementById('hello').innerHTML;
82
-
83
- expect(containerHTML).toEqual('Hello World');
84
- });
85
-
86
- test('Renders False Markup Booleans Properly', () => {
87
- document.body.innerHTML = '<div id="root"></div>';
88
-
89
- const Comp = component({
90
- state: { show: false },
91
- render() {
92
- return h('div', { class: 'container' }, [
93
- this.getState().show &&
94
- h('span', { id: 'hello' }, 'Hello World')
95
- ]);
96
- }
97
- });
98
-
99
- render(Comp, 'root', {});
100
-
101
- const element = document.getElementById('hello');
102
-
103
- expect(element).toBe(null);
104
- });
105
-
106
- test('getState and setState Works With Methods', () => {
107
- document.body.innerHTML = '<div id="root"></div>';
108
-
109
- const Comp2 = component({
110
- state: { count: 1 },
111
- methods() {
112
- return {
113
- increment() {
114
- this.setState((state) => ({ count: state.count + 1 }));
115
- },
116
- currentCount() {
117
- return this.getState().count;
118
- }
119
- };
120
- },
121
- render() {
122
- return h(
123
- 'button',
124
- {
125
- id: 'button',
126
- events: {
127
- click: () => {
128
- this.increment();
129
- setTimeout(() => {
130
- const countHTML = document.getElementById('count').innerHTML;
131
- expect(countHTML).toBe('2');
132
- done();
133
- });
134
- },
135
- },
136
- },
137
- [
138
- 'Click Me',
139
- h('span', { id: 'count' }, this.currentCount())
140
- ]
141
- );
142
- }
143
- });
144
-
145
- const Comp = component({
146
- render() {
147
- return h('div', { class: 'container' }, Comp2());
148
- }
149
- });
150
-
151
- render(Comp, 'root', {});
152
-
153
- document.getElementById('button').click();
154
- });
155
-
156
- test('getState and setState Works In Render Event', () => {
157
- document.body.innerHTML = '<div id="root"></div>';
158
-
159
- const Comp2 = component({
160
- state: { count: 1 },
161
- render() {
162
- return h(
163
- 'button',
164
- {
165
- id: 'button',
166
- events: {
167
- click: () => {
168
- this.setState((state) => ({ count: state.count + 1 }));
169
- setTimeout(() => {
170
- const countHTML = document.getElementById('count').innerHTML;
171
- expect(countHTML).toBe('2');
172
- done();
173
- });
174
- },
175
- },
176
- },
177
- [
178
- 'Click Me',
179
- h('span', { id: 'count' }, this.getState().count),
180
- ]
181
- );
182
- },
183
- });
184
-
185
- const Comp = component({
186
- render() {
187
- return h('div', { class: 'container' }, Comp2());
188
- },
189
- });
190
-
191
- render(Comp, 'root', {});
192
-
193
- document.getElementById('button').click();
194
- });
195
- });