1+ import { createTestingPinia } from "@pinia/testing" ;
12import { getLocalVue } from "@tests/vitest/helpers" ;
23import { mount } from "@vue/test-utils" ;
34import flushPromises from "flush-promises" ;
4- import { describe , expect , it } from "vitest" ;
5+ import { describe , expect , it , vi } from "vitest" ;
56
67import { useServerMock } from "@/api/client/__mocks__" ;
78
@@ -44,19 +45,23 @@ const USER_OBJECT_STORE_DATA = {
4445 variables : { } ,
4546} ;
4647
47- describe ( "ShowSelectedObjectStore" , ( ) => {
48- let wrapper ;
48+ function mountWithPreferredStoreId ( preferredObjectStoreId ) {
49+ const wrapper = mount ( ShowSelectedObjectStore , {
50+ propsData : { preferredObjectStoreId, forWhat : "Data goes into..." } ,
51+ localVue,
52+ pinia : createTestingPinia ( { createSpy : vi . fn } ) ,
53+ } ) ;
54+ return wrapper ;
55+ }
4956
57+ describe ( "ShowSelectedObjectStore" , ( ) => {
5058 it ( "should show a loading message and then a DescribeObjectStore component" , async ( ) => {
5159 server . use (
5260 http . get ( "/api/object_stores/{object_store_id}" , ( { response } ) => {
5361 return response ( 200 ) . json ( OBJECT_STORE_DATA ) ;
5462 } ) ,
5563 ) ;
56- wrapper = mount ( ShowSelectedObjectStore , {
57- propsData : { preferredObjectStoreId : TEST_OBJECT_ID , forWhat : "Data goes into..." } ,
58- localVue,
59- } ) ;
64+ const wrapper = mountWithPreferredStoreId ( TEST_OBJECT_ID ) ;
6065 let loadingEl = wrapper . findComponent ( LoadingSpan ) ;
6166 expect ( loadingEl . exists ( ) ) . toBeTruthy ( ) ;
6267 expect ( loadingEl . find ( ".loading-message" ) . text ( ) ) . toContain ( "Loading Galaxy storage details" ) ;
@@ -73,10 +78,7 @@ describe("ShowSelectedObjectStore", () => {
7378 } ) ,
7479 ) ;
7580
76- wrapper = mount ( ShowSelectedObjectStore , {
77- propsData : { preferredObjectStoreId : TEST_USER_OBJECT_STORE_ID , forWhat : "Data goes into..." } ,
78- localVue,
79- } ) ;
81+ const wrapper = mountWithPreferredStoreId ( TEST_USER_OBJECT_STORE_ID ) ;
8082 let loadingEl = wrapper . findComponent ( LoadingSpan ) ;
8183 expect ( loadingEl . exists ( ) ) . toBeTruthy ( ) ;
8284 expect ( loadingEl . find ( ".loading-message" ) . text ( ) ) . toContain ( "Loading Galaxy storage details" ) ;
0 commit comments