@data-client/vue 0.2.0 → 0.3.0
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/README.md +1 -24
- package/dist/index.js +185 -35
- package/dist/index.umd.min.js +1 -1
- package/lib/consumers/index.d.ts +2 -0
- package/lib/consumers/index.d.ts.map +1 -1
- package/lib/consumers/index.js +3 -1
- package/lib/consumers/useCache.d.ts +12 -0
- package/lib/consumers/useCache.d.ts.map +1 -0
- package/lib/consumers/useCache.js +63 -0
- package/lib/consumers/useDLE.d.ts +18 -0
- package/lib/consumers/useDLE.d.ts.map +1 -0
- package/lib/consumers/useDLE.js +88 -0
- package/lib/consumers/useFetch.d.ts +3 -2
- package/lib/consumers/useFetch.d.ts.map +1 -1
- package/lib/consumers/useFetch.js +10 -8
- package/lib/consumers/useLive.d.ts +3 -2
- package/lib/consumers/useLive.d.ts.map +1 -1
- package/lib/consumers/useLive.js +1 -1
- package/lib/consumers/useQuery.d.ts +3 -2
- package/lib/consumers/useQuery.d.ts.map +1 -1
- package/lib/consumers/useQuery.js +7 -3
- package/lib/consumers/useSubscription.d.ts +2 -1
- package/lib/consumers/useSubscription.d.ts.map +1 -1
- package/lib/consumers/useSubscription.js +1 -2
- package/lib/consumers/useSuspense.d.ts +3 -2
- package/lib/consumers/useSuspense.d.ts.map +1 -1
- package/lib/consumers/useSuspense.js +15 -20
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/providers/DataClientPlugin.d.ts +6 -0
- package/lib/providers/DataClientPlugin.d.ts.map +1 -1
- package/lib/providers/DataClientPlugin.js +15 -11
- package/lib/providers/index.d.ts +1 -1
- package/lib/providers/index.d.ts.map +1 -1
- package/lib/providers/index.js +1 -1
- package/lib/test/index.d.ts +3 -4
- package/lib/test/index.d.ts.map +1 -1
- package/lib/test/index.js +3 -5
- package/lib/test/mountDataClient.d.ts +29 -0
- package/lib/test/mountDataClient.d.ts.map +1 -0
- package/lib/test/mountDataClient.js +114 -0
- package/lib/test/renderDataCompose.d.ts +19 -0
- package/lib/test/renderDataCompose.d.ts.map +1 -0
- package/lib/test/renderDataCompose.js +135 -0
- package/lib/types.d.ts +10 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/package.json +6 -6
- package/src/__tests__/context.test.ts +195 -0
- package/src/__tests__/integration-garbage-collection.web.ts +12 -15
- package/src/__tests__/useCache.web.ts +391 -0
- package/src/__tests__/useDLE.web.ts +660 -0
- package/src/__tests__/useQuery.web.ts +332 -50
- package/src/__tests__/useSubscription.web.ts +233 -119
- package/src/__tests__/useSuspense.web.ts +176 -50
- package/src/consumers/index.ts +2 -0
- package/src/consumers/useCache.ts +122 -0
- package/src/consumers/useDLE.ts +160 -0
- package/src/consumers/useFetch.ts +24 -13
- package/src/consumers/useLive.ts +6 -2
- package/src/consumers/useQuery.ts +14 -5
- package/src/consumers/useSubscription.ts +5 -1
- package/src/consumers/useSuspense.ts +29 -17
- package/src/index.ts +4 -0
- package/src/providers/DataClientPlugin.ts +25 -10
- package/src/providers/__tests__/DataClientPlugin.test.ts +204 -4
- package/src/providers/__tests__/createDataClient.test.ts +234 -0
- package/src/providers/__tests__/getDefaultManagers.test.ts +180 -0
- package/src/providers/index.ts +5 -1
- package/src/test/README.md +77 -16
- package/src/test/__tests__/mountDataClient.test.ts +426 -0
- package/src/test/__tests__/renderDataCompose.test.ts +586 -0
- package/src/test/index.ts +3 -9
- package/src/test/mountDataClient.ts +169 -0
- package/src/test/renderDataCompose.ts +150 -0
- package/src/types.ts +11 -0
- package/ts3.4/consumers/index.d.ts +2 -0
- package/ts3.4/consumers/useCache.d.ts +14 -0
- package/ts3.4/consumers/useDLE.d.ts +20 -0
- package/ts3.4/consumers/useFetch.d.ts +3 -6
- package/ts3.4/consumers/useLive.d.ts +3 -6
- package/ts3.4/consumers/useQuery.d.ts +3 -2
- package/ts3.4/consumers/useSubscription.d.ts +2 -3
- package/ts3.4/consumers/useSuspense.d.ts +3 -6
- package/ts3.4/index.d.ts +1 -0
- package/ts3.4/providers/DataClientPlugin.d.ts +6 -0
- package/ts3.4/providers/index.d.ts +1 -1
- package/ts3.4/test/index.d.ts +3 -4
- package/ts3.4/test/mountDataClient.d.ts +29 -0
- package/ts3.4/test/renderDataCompose.d.ts +19 -0
- package/ts3.4/types.d.ts +10 -0
- package/lib/test/renderDataClient.d.ts +0 -40
- package/lib/test/renderDataClient.d.ts.map +0 -1
- package/lib/test/renderDataClient.js +0 -264
- package/src/__tests__/__snapshots__/useSubscription.web.ts.snap +0 -7
- package/src/test/renderDataClient.ts +0 -316
- package/ts3.4/test/renderDataClient.d.ts +0 -40
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import { defineComponent, h, computed, watch, reactive, nextTick } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { CoolerArticleResource } from '../../../../../__tests__/new';
|
|
4
|
+
import { mountDataClient } from '../mountDataClient';
|
|
5
|
+
|
|
6
|
+
describe('mountDataClient', () => {
|
|
7
|
+
const payload = {
|
|
8
|
+
id: 5,
|
|
9
|
+
title: 'hi ho',
|
|
10
|
+
content: 'whatever',
|
|
11
|
+
tags: ['a', 'best', 'react'],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe('basic behaviors', () => {
|
|
15
|
+
it('should render a component', () => {
|
|
16
|
+
const TestComponent = defineComponent({
|
|
17
|
+
name: 'TestComponent',
|
|
18
|
+
setup() {
|
|
19
|
+
return () => h('div', { 'data-testid': 'test' }, 'Hello World');
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent);
|
|
24
|
+
|
|
25
|
+
expect(wrapper.find('[data-testid="test"]').exists()).toBe(true);
|
|
26
|
+
expect(wrapper.find('[data-testid="test"]').text()).toBe('Hello World');
|
|
27
|
+
|
|
28
|
+
cleanup();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should provide a controller', () => {
|
|
32
|
+
const TestComponent = defineComponent({
|
|
33
|
+
name: 'TestComponent',
|
|
34
|
+
setup() {
|
|
35
|
+
return () => h('div', 'Test');
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const { controller, cleanup } = mountDataClient(TestComponent);
|
|
40
|
+
|
|
41
|
+
expect(controller).toBeDefined();
|
|
42
|
+
expect(controller.fetch).toBeDefined();
|
|
43
|
+
expect(controller.setResponse).toBeDefined();
|
|
44
|
+
|
|
45
|
+
cleanup();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should pass props to component', () => {
|
|
49
|
+
const TestComponent = defineComponent({
|
|
50
|
+
name: 'TestComponent',
|
|
51
|
+
props: {
|
|
52
|
+
message: {
|
|
53
|
+
type: String,
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
56
|
+
count: {
|
|
57
|
+
type: Number,
|
|
58
|
+
required: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
setup(props) {
|
|
62
|
+
return () =>
|
|
63
|
+
h('div', [
|
|
64
|
+
h('span', { 'data-testid': 'message' }, props.message),
|
|
65
|
+
h('span', { 'data-testid': 'count' }, String(props.count)),
|
|
66
|
+
]);
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const props = reactive({ message: 'Hello', count: 42 });
|
|
71
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent, { props });
|
|
72
|
+
|
|
73
|
+
expect(wrapper.find('[data-testid="message"]').text()).toBe('Hello');
|
|
74
|
+
expect(wrapper.find('[data-testid="count"]').text()).toBe('42');
|
|
75
|
+
|
|
76
|
+
cleanup();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should handle Suspense fallback', () => {
|
|
80
|
+
const TestComponent = defineComponent({
|
|
81
|
+
name: 'TestComponent',
|
|
82
|
+
setup() {
|
|
83
|
+
return () => h('div', 'Test');
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent);
|
|
88
|
+
|
|
89
|
+
// The component should eventually render (not stuck in fallback)
|
|
90
|
+
expect(wrapper.find('[data-testid="suspense-fallback"]').exists()).toBe(
|
|
91
|
+
false,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
cleanup();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should provide initial fixtures to the store', async () => {
|
|
98
|
+
const TestComponent = defineComponent({
|
|
99
|
+
name: 'TestComponent',
|
|
100
|
+
setup() {
|
|
101
|
+
return () => h('div', 'Test');
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const { controller, cleanup } = mountDataClient(TestComponent, {
|
|
106
|
+
initialFixtures: [
|
|
107
|
+
{
|
|
108
|
+
endpoint: CoolerArticleResource.get,
|
|
109
|
+
args: [{ id: payload.id }],
|
|
110
|
+
response: payload,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Just verify that we can render with fixtures
|
|
116
|
+
expect(controller).toBeDefined();
|
|
117
|
+
|
|
118
|
+
cleanup();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should cleanup properly', () => {
|
|
122
|
+
const TestComponent = defineComponent({
|
|
123
|
+
name: 'TestComponent',
|
|
124
|
+
setup() {
|
|
125
|
+
return () => h('div', { 'data-testid': 'test-div' }, 'Test');
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent);
|
|
130
|
+
|
|
131
|
+
expect(wrapper.find('[data-testid="test-div"]').exists()).toBe(true);
|
|
132
|
+
|
|
133
|
+
// Cleanup should not throw
|
|
134
|
+
expect(() => cleanup()).not.toThrow();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should handle allSettled()', async () => {
|
|
138
|
+
const TestComponent = defineComponent({
|
|
139
|
+
name: 'TestComponent',
|
|
140
|
+
setup() {
|
|
141
|
+
return () => h('div', 'Test');
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const { allSettled, cleanup } = mountDataClient(TestComponent);
|
|
146
|
+
|
|
147
|
+
const result = await allSettled();
|
|
148
|
+
|
|
149
|
+
expect(Array.isArray(result)).toBe(true);
|
|
150
|
+
|
|
151
|
+
cleanup();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe('reactive prop changes', () => {
|
|
156
|
+
it('should re-render when reactive props change', async () => {
|
|
157
|
+
const renderSpy = jest.fn();
|
|
158
|
+
|
|
159
|
+
const TestComponent = defineComponent({
|
|
160
|
+
name: 'TestComponent',
|
|
161
|
+
props: {
|
|
162
|
+
message: {
|
|
163
|
+
type: String,
|
|
164
|
+
required: true,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
setup(props) {
|
|
168
|
+
return () => {
|
|
169
|
+
renderSpy();
|
|
170
|
+
return h('div', { 'data-testid': 'message' }, props.message);
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const props = reactive({ message: 'Initial' });
|
|
176
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent, { props });
|
|
177
|
+
|
|
178
|
+
// Initial render
|
|
179
|
+
expect(wrapper.find('[data-testid="message"]').text()).toBe('Initial');
|
|
180
|
+
const initialCallCount = renderSpy.mock.calls.length;
|
|
181
|
+
|
|
182
|
+
// Change props - should trigger re-render
|
|
183
|
+
props.message = 'Updated';
|
|
184
|
+
await nextTick();
|
|
185
|
+
|
|
186
|
+
expect(wrapper.find('[data-testid="message"]').text()).toBe('Updated');
|
|
187
|
+
expect(renderSpy.mock.calls.length).toBeGreaterThan(initialCallCount);
|
|
188
|
+
|
|
189
|
+
cleanup();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should re-render when multiple props change', async () => {
|
|
193
|
+
const TestComponent = defineComponent({
|
|
194
|
+
name: 'TestComponent',
|
|
195
|
+
props: {
|
|
196
|
+
title: {
|
|
197
|
+
type: String,
|
|
198
|
+
required: true,
|
|
199
|
+
},
|
|
200
|
+
count: {
|
|
201
|
+
type: Number,
|
|
202
|
+
required: true,
|
|
203
|
+
},
|
|
204
|
+
enabled: {
|
|
205
|
+
type: Boolean,
|
|
206
|
+
required: true,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
setup(props) {
|
|
210
|
+
return () =>
|
|
211
|
+
h('div', [
|
|
212
|
+
h('h1', { 'data-testid': 'title' }, props.title),
|
|
213
|
+
h('span', { 'data-testid': 'count' }, String(props.count)),
|
|
214
|
+
h(
|
|
215
|
+
'span',
|
|
216
|
+
{ 'data-testid': 'enabled' },
|
|
217
|
+
props.enabled ? 'Yes' : 'No',
|
|
218
|
+
),
|
|
219
|
+
]);
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const props = reactive({
|
|
224
|
+
title: 'Original',
|
|
225
|
+
count: 0,
|
|
226
|
+
enabled: false,
|
|
227
|
+
});
|
|
228
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent, { props });
|
|
229
|
+
|
|
230
|
+
// Initial state
|
|
231
|
+
expect(wrapper.find('[data-testid="title"]').text()).toBe('Original');
|
|
232
|
+
expect(wrapper.find('[data-testid="count"]').text()).toBe('0');
|
|
233
|
+
expect(wrapper.find('[data-testid="enabled"]').text()).toBe('No');
|
|
234
|
+
|
|
235
|
+
// Change all props
|
|
236
|
+
props.title = 'Changed';
|
|
237
|
+
props.count = 42;
|
|
238
|
+
props.enabled = true;
|
|
239
|
+
await nextTick();
|
|
240
|
+
|
|
241
|
+
expect(wrapper.find('[data-testid="title"]').text()).toBe('Changed');
|
|
242
|
+
expect(wrapper.find('[data-testid="count"]').text()).toBe('42');
|
|
243
|
+
expect(wrapper.find('[data-testid="enabled"]').text()).toBe('Yes');
|
|
244
|
+
|
|
245
|
+
cleanup();
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('should handle nested reactive objects', async () => {
|
|
249
|
+
const TestComponent = defineComponent({
|
|
250
|
+
name: 'TestComponent',
|
|
251
|
+
props: {
|
|
252
|
+
user: {
|
|
253
|
+
type: Object,
|
|
254
|
+
required: true,
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
setup(props) {
|
|
258
|
+
return () =>
|
|
259
|
+
h('div', [
|
|
260
|
+
h('span', { 'data-testid': 'name' }, (props.user as any).name),
|
|
261
|
+
h(
|
|
262
|
+
'span',
|
|
263
|
+
{ 'data-testid': 'age' },
|
|
264
|
+
String((props.user as any).age),
|
|
265
|
+
),
|
|
266
|
+
]);
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const props = reactive({
|
|
271
|
+
user: { name: 'Alice', age: 25 },
|
|
272
|
+
});
|
|
273
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent, { props });
|
|
274
|
+
|
|
275
|
+
// Initial state
|
|
276
|
+
expect(wrapper.find('[data-testid="name"]').text()).toBe('Alice');
|
|
277
|
+
expect(wrapper.find('[data-testid="age"]').text()).toBe('25');
|
|
278
|
+
|
|
279
|
+
// Update nested property
|
|
280
|
+
props.user = { name: 'Bob', age: 30 };
|
|
281
|
+
await nextTick();
|
|
282
|
+
|
|
283
|
+
expect(wrapper.find('[data-testid="name"]').text()).toBe('Bob');
|
|
284
|
+
expect(wrapper.find('[data-testid="age"]').text()).toBe('30');
|
|
285
|
+
|
|
286
|
+
cleanup();
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('should trigger component computed values when props change', async () => {
|
|
290
|
+
const TestComponent = defineComponent({
|
|
291
|
+
name: 'TestComponent',
|
|
292
|
+
props: {
|
|
293
|
+
firstName: {
|
|
294
|
+
type: String,
|
|
295
|
+
required: true,
|
|
296
|
+
},
|
|
297
|
+
lastName: {
|
|
298
|
+
type: String,
|
|
299
|
+
required: true,
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
setup(props) {
|
|
303
|
+
const fullName = computed(
|
|
304
|
+
() => `${props.firstName} ${props.lastName}`,
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
return () => h('div', { 'data-testid': 'full-name' }, fullName.value);
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const props = reactive({
|
|
312
|
+
firstName: 'John',
|
|
313
|
+
lastName: 'Doe',
|
|
314
|
+
});
|
|
315
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent, { props });
|
|
316
|
+
|
|
317
|
+
// Initial computed value
|
|
318
|
+
expect(wrapper.find('[data-testid="full-name"]').text()).toBe('John Doe');
|
|
319
|
+
|
|
320
|
+
// Change first name only
|
|
321
|
+
props.firstName = 'Jane';
|
|
322
|
+
await nextTick();
|
|
323
|
+
|
|
324
|
+
expect(wrapper.find('[data-testid="full-name"]').text()).toBe('Jane Doe');
|
|
325
|
+
|
|
326
|
+
// Change last name
|
|
327
|
+
props.lastName = 'Smith';
|
|
328
|
+
await nextTick();
|
|
329
|
+
|
|
330
|
+
expect(wrapper.find('[data-testid="full-name"]').text()).toBe(
|
|
331
|
+
'Jane Smith',
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
cleanup();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('should trigger component watchers when props change', async () => {
|
|
338
|
+
const watchSpy = jest.fn();
|
|
339
|
+
|
|
340
|
+
const TestComponent = defineComponent({
|
|
341
|
+
name: 'TestComponent',
|
|
342
|
+
props: {
|
|
343
|
+
value: {
|
|
344
|
+
type: Number,
|
|
345
|
+
required: true,
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
setup(props) {
|
|
349
|
+
watch(
|
|
350
|
+
() => props.value,
|
|
351
|
+
(newVal, oldVal) => {
|
|
352
|
+
watchSpy(newVal, oldVal);
|
|
353
|
+
},
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
return () =>
|
|
357
|
+
h('div', { 'data-testid': 'value' }, String(props.value));
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
const props = reactive({ value: 1 });
|
|
362
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent, { props });
|
|
363
|
+
|
|
364
|
+
// Initial value
|
|
365
|
+
expect(wrapper.find('[data-testid="value"]').text()).toBe('1');
|
|
366
|
+
expect(watchSpy).not.toHaveBeenCalled(); // watch doesn't fire on initial setup
|
|
367
|
+
|
|
368
|
+
// Change value
|
|
369
|
+
props.value = 2;
|
|
370
|
+
await nextTick();
|
|
371
|
+
|
|
372
|
+
expect(wrapper.find('[data-testid="value"]').text()).toBe('2');
|
|
373
|
+
expect(watchSpy).toHaveBeenCalledWith(2, 1);
|
|
374
|
+
|
|
375
|
+
// Change again
|
|
376
|
+
props.value = 5;
|
|
377
|
+
await nextTick();
|
|
378
|
+
|
|
379
|
+
expect(wrapper.find('[data-testid="value"]').text()).toBe('5');
|
|
380
|
+
expect(watchSpy).toHaveBeenCalledWith(5, 2);
|
|
381
|
+
|
|
382
|
+
cleanup();
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it('should handle array prop changes', async () => {
|
|
386
|
+
const TestComponent = defineComponent({
|
|
387
|
+
name: 'TestComponent',
|
|
388
|
+
props: {
|
|
389
|
+
items: {
|
|
390
|
+
type: Array,
|
|
391
|
+
required: true,
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
setup(props) {
|
|
395
|
+
return () =>
|
|
396
|
+
h(
|
|
397
|
+
'ul',
|
|
398
|
+
{ 'data-testid': 'list' },
|
|
399
|
+
(props.items as string[]).map(item => h('li', item)),
|
|
400
|
+
);
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
const props = reactive({
|
|
405
|
+
items: ['Apple', 'Banana'],
|
|
406
|
+
});
|
|
407
|
+
const { wrapper, cleanup } = mountDataClient(TestComponent, { props });
|
|
408
|
+
|
|
409
|
+
// Initial list
|
|
410
|
+
expect(wrapper.findAll('li').length).toBe(2);
|
|
411
|
+
expect(wrapper.findAll('li')[0].text()).toBe('Apple');
|
|
412
|
+
expect(wrapper.findAll('li')[1].text()).toBe('Banana');
|
|
413
|
+
|
|
414
|
+
// Update array
|
|
415
|
+
props.items = ['Orange', 'Grape', 'Melon'];
|
|
416
|
+
await nextTick();
|
|
417
|
+
|
|
418
|
+
expect(wrapper.findAll('li').length).toBe(3);
|
|
419
|
+
expect(wrapper.findAll('li')[0].text()).toBe('Orange');
|
|
420
|
+
expect(wrapper.findAll('li')[1].text()).toBe('Grape');
|
|
421
|
+
expect(wrapper.findAll('li')[2].text()).toBe('Melon');
|
|
422
|
+
|
|
423
|
+
cleanup();
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
});
|