Skip to content

Commit

Permalink
tests(suggestion): fix emitting events tests
Browse files Browse the repository at this point in the history
  • Loading branch information
annacv committed Mar 25, 2024
1 parent 66590f1 commit ddc66ea
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import { Suggestion } from '@empathyco/x-types';
import { mount, Wrapper } from '@vue/test-utils';
import Vue from 'vue';
import { createQuerySuggestion } from '../../../__stubs__/index';
import { XPlugin } from '../../../plugins/x-plugin';
import { normalizeString } from '../../../utils/normalize';
import { XEventsTypes } from '../../../wiring/events.types';
import { WireMetadata } from '../../../wiring/wiring.types';
import { getDataTestSelector, installNewXPlugin } from '../../../__tests__/utils';
import BaseSuggestion from '../base-suggestion.vue';
import { createSimpleFacetStub } from '../../../__stubs__/facets-stubs.factory';
import { createPopularSearch } from '../../../__stubs__/popular-searches-stubs.factory';
import { bus } from '../../../plugins/index';

function renderBaseSuggestion({
query = 'bebe',
suggestion = createPopularSearch('bebe lloron'),
suggestionSelectedEvents = {}
}: BaseSuggestionOptions = {}): BaseSuggestionAPI {
const [, localVue] = installNewXPlugin();
const emit = jest.spyOn(XPlugin.bus, 'emit');
const emit = jest.spyOn(bus, 'emit');
const wrapper = mount(
{
components: { BaseSuggestion },
Expand Down Expand Up @@ -56,6 +56,14 @@ function renderBaseSuggestion({
}

describe('testing Base Suggestion component', () => {
beforeAll(() => {
jest.useFakeTimers();
});

beforeEach(() => {
jest.clearAllMocks();
});

it('renders a basic suggestion', () => {
const { wrapper } = renderBaseSuggestion({
suggestion: createPopularSearch('milk')
Expand Down

0 comments on commit ddc66ea

Please sign in to comment.