Skip to content

Commit

Permalink
test: adjust wiring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
diegopf committed Aug 15, 2024
1 parent c49cdd5 commit 8263f26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DeepPartial } from '@empathyco/x-utils';
import { createLocalVue } from '@vue/test-utils';
import Vuex, { Store } from 'vuex';
import { mount } from '@vue/test-utils';
import { createStore, Store } from 'vuex';
import { EventPayload, SubjectPayload, XBus } from '@empathyco/x-bus';
import { Observable } from 'rxjs';
import { RootXStoreState } from '../../store/index';
Expand All @@ -19,16 +19,15 @@ export function createWire<SomeEvent extends XEvent = 'UserIsTypingAQuery'>({
event = 'UserIsTypingAQuery' as SomeEvent,
state
}: CreateWireOptions<SomeEvent> = {}): CreateWireAPI<XEventPayload<SomeEvent>> {
const vue = createLocalVue();
vue.use(Vuex);
const store = createStore({
state: { x: state }
}) as Store<RootXStoreState>;
mount({}, { global: { plugins: [store] } });
const bus = new XDummyBus();
const callback = jest.fn();
const wire = createWireFromFunction<XEventPayload<SomeEvent>>(({ eventPayload }) => {
callback(eventPayload);
});
const store = new Store<DeepPartial<RootXStoreState>>({
state: { x: state }
}) as Store<RootXStoreState>;

return {
store,
Expand Down
9 changes: 4 additions & 5 deletions packages/x-components/src/wiring/__tests__/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createLocalVue } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import { Subject } from 'rxjs';
import Vuex, { Store } from 'vuex';
import { createStore, Store } from 'vuex';
import { RootXStoreState } from '../../store/store.types';
import { XModuleName } from '../../x-modules/x-modules.types';
import { WireParams, WirePayload } from '../wiring.types';
Expand All @@ -13,9 +13,7 @@ import { WireParams, WirePayload } from '../wiring.types';
* @internal
*/
export function createQuerySuggestionsStoreMock(): Store<any> {
const localVue = createLocalVue();
localVue.use(Vuex);
const store = new Store<any>({
const store = createStore<any>({
state: () => ({
x: {
querySuggestions: {
Expand All @@ -31,6 +29,7 @@ export function createQuerySuggestionsStoreMock(): Store<any> {
state.x.querySuggestions.query.trim()
}
});
mount({}, { global: { plugins: [store] } });
store.commit = jest.fn();
store.dispatch = jest.fn();
return store;
Expand Down

0 comments on commit 8263f26

Please sign in to comment.