Skip to content

Commit 211fe8f

Browse files
rushk014xingzhang-suse
authored andcommitted
test: Add $fetchState stubs to resolve jest failures (#346)
1 parent e856a9c commit 211fe8f

File tree

5 files changed

+45
-34
lines changed

5 files changed

+45
-34
lines changed

pkg/sbomscanner-ui-ext/components/__tests__/ImageDetails.spec.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ describe('ImageDetails.vue', () => {
5656
wrapper = shallowMount(ImageDetails, {
5757
global: {
5858
mocks: {
59-
$t: mockT,
60-
t: mockT,
61-
$store: mockStore,
62-
$route: { params: { id: 'test-image-route', cluster: 'test-cluster' } },
59+
$fetchState: { pending: false },
60+
$t: mockT,
61+
t: mockT,
62+
$store: mockStore,
63+
$route: { params: { id: 'test-image-route', cluster: 'test-cluster' } },
6364
},
65+
stubs: { RouterLink: { template: '<a><slot /></a>', props: ['to'] } }
6466
},
6567
data() {
6668
return { imageName: 'test-image' };
@@ -88,11 +90,13 @@ describe('ImageDetails.vue', () => {
8890
const wrapper = shallowMount(ImageDetails, {
8991
global: {
9092
mocks: {
91-
$t: mockT,
92-
t: mockT,
93-
$store: mockStore,
94-
$route: { params: { cluster: 'test-cluster' } },
93+
$fetchState: { pending: false },
94+
$t: mockT,
95+
t: mockT,
96+
$store: mockStore,
97+
$route: { params: { cluster: 'test-cluster' } },
9598
},
99+
stubs: { RouterLink: { template: '<a><slot /></a>', props: ['to'] } }
96100
},
97101
data() {
98102
return { imageName: 'test-image' };
@@ -139,11 +143,13 @@ describe('ImageDetails.vue', () => {
139143
const localWrapper = shallowMount(ImageDetails, {
140144
global: {
141145
mocks: {
142-
$t: mockT,
143-
t: mockT,
144-
$store: localStore,
145-
$route: { params: { id: 'fallback', cluster: 'test-cluster' } },
146+
$fetchState: { pending: false },
147+
$t: mockT,
148+
t: mockT,
149+
$store: localStore,
150+
$route: { params: { id: 'fallback', cluster: 'test-cluster' } },
146151
},
152+
stubs: { RouterLink: { template: '<a><slot /></a>', props: ['to'] } }
147153
},
148154
data() {
149155
return { imageName: 'fallback' };

pkg/sbomscanner-ui-ext/components/__tests__/RegistryDetails.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ describe('RegistryDetails.vue', () => {
4949
return mount(RegistryDetails, {
5050
global: {
5151
mocks: {
52-
$store: storeMock,
52+
$store: storeMock,
53+
$fetchState: { pending: false },
5354
$route: {
5455
params: {
5556
cluster: 'local', id: 'my-reg', ns: 'ns1'

pkg/sbomscanner-ui-ext/list/__tests__/sbomscanner.kubewarden.io.vexhub.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ describe('VexHubList.vue', () => {
4545
'cluster/schemaFor': mockSchemaFor,
4646
}
4747
},
48-
$fetch: mockFetch,
48+
$fetch: mockFetch,
49+
$fetchState: { pending: false },
4950
},
5051
stubs: { ResourceTable: true }
5152
}

pkg/sbomscanner-ui-ext/pages/c/_cluster/sbomscanner/__tests__/Dashboard.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ describe('Dashboard.vue full coverage', () => {
4545
return shallowMount(Dashboard, {
4646
global: {
4747
mocks: {
48-
$store: storeMock,
49-
t: (key: any) => key,
48+
$store: storeMock,
49+
t: (key: any) => key,
50+
$fetchState: { pending: false },
5051
},
5152
},
5253
...options,
@@ -218,7 +219,8 @@ describe('Dashboard.vue full coverage', () => {
218219
dispatch: mockDispatch,
219220
getters: { 'cluster/all': jest.fn(() => []) },
220221
},
221-
t: (key) => key,
222+
t: (key) => key,
223+
$fetchState: { pending: false },
222224
},
223225
},
224226
});

pkg/sbomscanner-ui-ext/pages/c/_cluster/sbomscanner/__tests__/ImageOverview.spec.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('ImageOverview.vue', () => {
2222
$t: t,
2323
t,
2424
$store: store,
25+
$fetchState: { pending: false },
2526
$rootGetters: {},
2627
};
2728

@@ -68,7 +69,7 @@ describe('ImageOverview.vue', () => {
6869
const wrapper = mount(ImageOverview as any, {
6970
global: {
7071
mocks: {
71-
$store: store, $t: t, t
72+
$store: store, $t: t, t, $fetchState: { pending: false }
7273
},
7374
stubs: {
7475
SortableTable: SortableTableWithSlots,
@@ -239,7 +240,7 @@ describe('ImageOverview.vue', () => {
239240
const wrapperErr = mountComponent({
240241
global: {
241242
mocks: {
242-
$store: storeErr, $t: t, t, $rootGetters: {}
243+
$store: storeErr, $t: t, t, $rootGetters: {}, $fetchState: { pending: false }
243244
}
244245
}
245246
});
@@ -264,7 +265,7 @@ describe('ImageOverview.vue', () => {
264265
const wrapper = mountComponent({
265266
global: {
266267
mocks: {
267-
$store: store, $t: t, t
268+
$store: store, $t: t, t, $fetchState: { pending: false }
268269
}
269270
}
270271
});
@@ -469,7 +470,7 @@ describe('ImageOverview.vue', () => {
469470
const wrapperErr = mountComponent({
470471
global: {
471472
mocks: {
472-
$store: storeErr, $t: t, t, $rootGetters: {}
473+
$store: storeErr, $t: t, t, $rootGetters: {}, $fetchState: { pending: false }
473474
}
474475
}
475476
});
@@ -527,7 +528,7 @@ describe('ImageOverview.vue', () => {
527528
const wrapperSuccess = mountComponent({
528529
global: {
529530
mocks: {
530-
$store: storeSuccess, $t: t, t
531+
$store: storeSuccess, $t: t, t, $fetchState: { pending: false }
531532
}
532533
}
533534
});
@@ -552,7 +553,7 @@ describe('ImageOverview.vue', () => {
552553
const wrapperError = mountComponent({
553554
global: {
554555
mocks: {
555-
$store: storeError, $t: t, t
556+
$store: storeError, $t: t, t, $fetchState: { pending: false }
556557
}
557558
}
558559
});
@@ -577,7 +578,7 @@ describe('ImageOverview.vue', () => {
577578
const wrapper = mountComponent({
578579
global: {
579580
mocks: {
580-
$store: storeSuccess, $t: t, t
581+
$store: storeSuccess, $t: t, t, $fetchState: { pending: false }
581582
}
582583
}
583584
});
@@ -598,7 +599,7 @@ describe('ImageOverview.vue', () => {
598599
const wrapperErr = mountComponent({
599600
global: {
600601
mocks: {
601-
$store: storeError, $t: t, t
602+
$store: storeError, $t: t, t, $fetchState: { pending: false }
602603
}
603604
}
604605
});
@@ -626,7 +627,7 @@ describe('ImageOverview.vue', () => {
626627
const wrapper = mountComponent({
627628
global: {
628629
mocks: {
629-
$store: storeSuccess, $t: t, t
630+
$store: storeSuccess, $t: t, t, $fetchState: { pending: false }
630631
}
631632
}
632633
});
@@ -648,7 +649,7 @@ describe('ImageOverview.vue', () => {
648649
const wrapperErr = mountComponent({
649650
global: {
650651
mocks: {
651-
$store: storeError, $t: t, t
652+
$store: storeError, $t: t, t, $fetchState: { pending: false }
652653
}
653654
}
654655
});
@@ -694,7 +695,7 @@ describe('ImageOverview.vue', () => {
694695
const wrapper = mountComponent({
695696
global: {
696697
mocks: {
697-
$store: store, $t: t, t
698+
$store: store, $t: t, t, $fetchState: { pending: false }
698699
}
699700
}
700701
});
@@ -733,7 +734,7 @@ describe('ImageOverview.vue', () => {
733734
const wrapperSuccess = mountComponent({
734735
global: {
735736
mocks: {
736-
$store: storeSuccess, $t: t, t
737+
$store: storeSuccess, $t: t, t, $fetchState: { pending: false }
737738
}
738739
}
739740
});
@@ -758,7 +759,7 @@ describe('ImageOverview.vue', () => {
758759
const wrapperError = mountComponent({
759760
global: {
760761
mocks: {
761-
$store: storeError, $t: t, t
762+
$store: storeError, $t: t, t, $fetchState: { pending: false }
762763
}
763764
}
764765
});
@@ -783,7 +784,7 @@ describe('ImageOverview.vue', () => {
783784
const wrapper = mountComponent({
784785
global: {
785786
mocks: {
786-
$store: storeSuccess, $t: t, t
787+
$store: storeSuccess, $t: t, t, $fetchState: { pending: false }
787788
}
788789
}
789790
});
@@ -804,7 +805,7 @@ describe('ImageOverview.vue', () => {
804805
const wrapperErr = mountComponent({
805806
global: {
806807
mocks: {
807-
$store: storeError, $t: t, t
808+
$store: storeError, $t: t, t, $fetchState: { pending: false }
808809
}
809810
}
810811
});
@@ -832,7 +833,7 @@ describe('ImageOverview.vue', () => {
832833
const wrapper = mountComponent({
833834
global: {
834835
mocks: {
835-
$store: storeSuccess, $t: t, t
836+
$store: storeSuccess, $t: t, t, $fetchState: { pending: false }
836837
}
837838
}
838839
});
@@ -854,7 +855,7 @@ describe('ImageOverview.vue', () => {
854855
const wrapperErr = mountComponent({
855856
global: {
856857
mocks: {
857-
$store: storeError, $t: t, t
858+
$store: storeError, $t: t, t, $fetchState: { pending: false }
858859
}
859860
}
860861
});

0 commit comments

Comments
 (0)