Skip to content

Commit

Permalink
tests: replace eventMetadata object by any object
Browse files Browse the repository at this point in the history
  • Loading branch information
annacv committed Mar 5, 2024
1 parent b1c518f commit 7ee475b
Showing 1 changed file with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ function renderPreselectedFilters({
}
});

const eventMetadata = {
moduleName: null,
location: 'none',
replaceable: true
};

function setSnippetConfig(newValue: Dictionary<unknown>): Promise<void> {
Object.assign(snippetConfig, newValue);
return localVue.nextTick();
Expand All @@ -45,8 +39,7 @@ function renderPreselectedFilters({
return {
wrapper,
emit,
setSnippetConfig,
eventMetadata
setSnippetConfig
};
}

Expand All @@ -65,7 +58,7 @@ describe('testing Preselected filters component', () => {
'{!tag=brand_facet}brand_facet:"Lego"',
'{!tag=age_facet}age_facet:"toddler"'
];
const { emit, eventMetadata } = renderPreselectedFilters({
const { emit } = renderPreselectedFilters({
snippetFilters
});

Expand All @@ -79,15 +72,15 @@ describe('testing Preselected filters component', () => {

it('emits the event when filters are provided by the prop', () => {
const filters = ['{!tag=brand_facet}brand_facet:"Lego"', '{!tag=age_facet}age_facet:"toddler"'];
const { emit, eventMetadata } = renderPreselectedFilters({
const { emit } = renderPreselectedFilters({
filters
});

expect(emit).toHaveBeenCalledTimes(1);
expect(emit).toHaveBeenCalledWith(
'PreselectedFiltersProvided',
createRawFilters(filters),
eventMetadata
expect.any(Object)
);
});

Expand All @@ -97,7 +90,7 @@ describe('testing Preselected filters component', () => {
'{!tag=brand_facet}brand_facet:"Nintendo"',
'{!tag=age_facet}age_facet:"kids"'
];
const { emit, eventMetadata } = renderPreselectedFilters({
const { emit } = renderPreselectedFilters({
filters,
snippetFilters
});
Expand All @@ -106,15 +99,15 @@ describe('testing Preselected filters component', () => {
expect(emit).toHaveBeenCalledWith(
'PreselectedFiltersProvided',
createRawFilters(snippetFilters),
eventMetadata
expect.any(Object)
);
});

it('emits the event when the prop filters change', async () => {
const filters = ['{!tag=brand_facet}brand_facet:"Lego"'];
const newFilters = ['{!tag=brand_facet}brand_facet:"Playmobil"'];

const { emit, eventMetadata, wrapper } = renderPreselectedFilters({
const { emit, wrapper } = renderPreselectedFilters({
filters
});

Expand All @@ -123,7 +116,7 @@ describe('testing Preselected filters component', () => {
expect(emit).toHaveBeenCalledWith(
'PreselectedFiltersProvided',
createRawFilters(filters),
eventMetadata
expect.any(Object)
);

await wrapper.setProps({ filters: newFilters });
Expand All @@ -133,15 +126,15 @@ describe('testing Preselected filters component', () => {
expect(emit).toHaveBeenCalledWith(
'PreselectedFiltersProvided',
createRawFilters(newFilters),
eventMetadata
expect.any(Object)
);
});

it('emits the event when the snippetConfig filters change', async () => {
const filters = ['{!tag=brand_facet}brand_facet:"Chorizo"'];
const newFilters = ['{!tag=brand_facet}brand_facet:"Chistorra"'];

const { emit, eventMetadata, wrapper, setSnippetConfig } = renderPreselectedFilters({
const { emit, wrapper, setSnippetConfig } = renderPreselectedFilters({
filters
});

Expand All @@ -150,7 +143,7 @@ describe('testing Preselected filters component', () => {
expect(emit).toHaveBeenCalledWith(
'PreselectedFiltersProvided',
createRawFilters(filters),
eventMetadata
expect.any(Object)
);

await setSnippetConfig({ filters: newFilters });
Expand All @@ -166,7 +159,7 @@ describe('testing Preselected filters component', () => {
expect(emit).toHaveBeenCalledWith(
'PreselectedFiltersProvided',
createRawFilters(newFilters),
eventMetadata
expect.any(Object)
);
});
});
Expand All @@ -191,6 +184,4 @@ interface RenderPreselectedFiltersAPI {
wrapper: Wrapper<Vue>;
/** Helper method to change the snippet config. */
setSnippetConfig: (newSnippetConfig: Dictionary<unknown>) => void | Promise<void>;
/** Metadata object returned by the {@link XBus.emit} function. */
eventMetadata: Dictionary<unknown>;
}

0 comments on commit 7ee475b

Please sign in to comment.