Skip to content

Commit c27966d

Browse files
committed
Provide single dummy component for tests
1 parent 4c6d7f3 commit c27966d

File tree

8 files changed

+36
-92
lines changed

8 files changed

+36
-92
lines changed

tests/components/Component.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script lang="ts">
2+
import { Vue, Component, Prop } from 'vue-property-decorator';
3+
4+
@Component
5+
export default class Input extends Vue {
6+
@Prop({
7+
default: null,
8+
}) readonly value!: any;
9+
}
10+
</script>
11+
12+
<template>
13+
<span class="dummy-component"/>
14+
</template>

tests/components/Input.vue

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/components/Number.vue

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/unit/colored-borders.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { mount } from '@vue/test-utils';
22
import { QueryBuilderConfig, RuleSet } from '@/types';
33
import QueryBuilder from '@/QueryBuilder.vue';
44
import QueryBuilderGroup from '@/QueryBuilderGroup.vue';
5-
import Number from '../components/Number.vue';
6-
import Input from '../components/Input.vue';
5+
import Component from '../components/Component.vue';
76

87
describe('Testing drag\'n\'drop related features', () => {
98
const config: QueryBuilderConfig = {
@@ -21,13 +20,13 @@ describe('Testing drag\'n\'drop related features', () => {
2120
{
2221
identifier: 'txt',
2322
name: 'Text Selection',
24-
component: Input,
23+
component: Component,
2524
initialValue: 'foo',
2625
},
2726
{
2827
identifier: 'num',
2928
name: 'Number Selection',
30-
component: Number,
29+
component: Component,
3130
initialValue: 10,
3231
},
3332
],

tests/unit/drag-n-drop.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import QueryBuilderGroup from '@/QueryBuilderGroup.vue';
55
import {
66
RuleSet, Rule, QueryBuilderConfig, QueryBuilderGroup as QueryBuilderGroupInterface,
77
} from '@/types';
8-
import Number from '../components/Number.vue';
9-
import Input from '../components/Input.vue';
8+
import Component from '../components/Component.vue';
109

1110
// Schedule a microtask, so all pending promises can be executed
1211
const flushPromises = (): Promise<void> => new Promise(res => setTimeout(res, 0));
@@ -86,13 +85,13 @@ describe('Test drag\'n\'drop related actions', () => {
8685
{
8786
identifier: 'txt',
8887
name: 'Text Selection',
89-
component: Input,
88+
component: Component,
9089
initialValue: '',
9190
},
9291
{
9392
identifier: 'num',
9493
name: 'Number Selection',
95-
component: Number,
94+
component: Component,
9695
initialValue: 10,
9796
},
9897
],

tests/unit/query-builder.spec.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { mount } from '@vue/test-utils';
2-
import Input from '../components/Input.vue';
3-
import Number from '../components/Number.vue';
2+
import Component from '../components/Component.vue';
43
import QueryBuilder from '@/QueryBuilder.vue';
54
import App from '../components/App.vue';
65
import QueryBuilderGroup from '@/QueryBuilderGroup.vue';
@@ -24,13 +23,13 @@ describe('Test basic functionality of QueryBuilder.vue', () => {
2423
{
2524
identifier: 'txt',
2625
name: 'Text Selection',
27-
component: Input,
26+
component: Component,
2827
initialValue: '',
2928
},
3029
{
3130
identifier: 'num',
3231
name: 'Number Selection',
33-
component: Number,
32+
component: Component,
3433
initialValue: 10,
3534
},
3635
],
@@ -106,8 +105,8 @@ describe('Test basic functionality of QueryBuilder.vue', () => {
106105
});
107106

108107
// Manually update value
109-
const num = wrapper.find(Number);
110-
num.setValue('20');
108+
const num = wrapper.find(Component);
109+
num.vm.$emit('input', 20);
111110
expect(wrapper.emittedByOrder()).toHaveLength(2);
112111
expect(wrapper.emittedByOrder()[1]).toStrictEqual({
113112
name: 'input',
@@ -149,13 +148,13 @@ describe('Test basic functionality of QueryBuilder.vue', () => {
149148
{
150149
identifier: 'txt',
151150
name: 'Text Selection',
152-
component: Input,
151+
component: Component,
153152
initialValue: '',
154153
},
155154
{
156155
identifier: 'num',
157156
name: 'Number Selection',
158-
component: Number,
157+
component: Component,
159158
initialValue: 10,
160159
},
161160
],
@@ -271,13 +270,13 @@ describe('Test basic functionality of QueryBuilder.vue', () => {
271270
{
272271
identifier: 'txt',
273272
name: 'Text Selection',
274-
component: Input,
273+
component: Component,
275274
initialValue: '',
276275
},
277276
{
278277
identifier: 'num',
279278
name: 'Number Selection',
280-
component: Number,
279+
component: Component,
281280
initialValue: 10,
282281
},
283282
],
@@ -384,7 +383,7 @@ describe('Test basic functionality of QueryBuilder.vue', () => {
384383
.filter(({ vm: { $props } }) => $props.query.identifier === 'txt' && $props.query.value === 'd')
385384
.at(0);
386385

387-
rule.find('input').setValue('D');
386+
rule.find('.dummy-component').vm.$emit('input', 'D');
388387
expect(app.vm.$data.query).toStrictEqual({
389388
operatorIdentifier: 'or',
390389
children: [

tests/unit/slots.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { RuleSet, Rule, QueryBuilderConfig } from '@/types';
33
import QueryBuilder from '@/QueryBuilder.vue';
44
import QueryBuilderGroup from '@/QueryBuilderGroup.vue';
55
import QueryBuilderRule from '@/QueryBuilderRule.vue';
6-
import Number from '../components/Number.vue';
7-
import Input from '../components/Input.vue';
6+
import Component from '../components/Component.vue';
87

98
describe('Testing slot related features', () => {
109
const propsData: { value: RuleSet, config: QueryBuilderConfig } = {
@@ -40,13 +39,13 @@ describe('Testing slot related features', () => {
4039
{
4140
identifier: 'txt',
4241
name: 'Text Selection',
43-
component: Input,
42+
component: Component,
4443
initialValue: 'foo',
4544
},
4645
{
4746
identifier: 'num',
4847
name: 'Number Selection',
49-
component: Number,
48+
component: Component,
5049
initialValue: 10,
5150
},
5251
],
@@ -195,7 +194,7 @@ describe('Testing slot related features', () => {
195194
const ruleComponent = slot.find('.slot-rule');
196195

197196
// Verify rule slot is properly rendered
198-
expect(ruleComponent.is(Input)).toBeTruthy();
197+
expect(ruleComponent.is(Component)).toBeTruthy();
199198
expect(ruleComponent.vm.$props.value).toBe('A');
200199
ruleComponent.vm.$emit('input', 'a');
201200
expect(rule.emitted()['query-update'][0][0]).toStrictEqual({ identifier: 'txt', value: 'a' });

tests/unit/validation.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Input from '../components/Input.vue';
1+
import Component from '../components/Component.vue';
22
import { isQueryBuilderConfig, isRule, isRuleSet } from '@/guards';
33

44
describe('Testing component props and guards', () => {
@@ -26,7 +26,7 @@ describe('Testing component props and guards', () => {
2626
{
2727
identifier: 'baz',
2828
name: 'baz',
29-
component: Input,
29+
component: Component,
3030
},
3131
],
3232
},

0 commit comments

Comments
 (0)