Fix unit tests

- fix one issue brought in by pr
- fix warning related to namespaceFilterMode
This commit is contained in:
Richard Cox 2022-12-23 09:56:38 +00:00
parent a39e40c2c1
commit e19c7c043a
1 changed files with 33 additions and 26 deletions

View File

@ -25,7 +25,7 @@ describe('component: NamespaceFilter', () => {
options: () => [], options: () => [],
value: () => [], value: () => [],
}, },
mocks: { $store: { getters: { 'i18n/t': () => text } } }, mocks: { $store: { getters: { 'i18n/t': () => text, namespaceFilterMode: () => undefined } } },
directives: { shortkey: () => jest.fn() } directives: { shortkey: () => jest.fn() }
}); });
const element = wrapper.find(`[data-testid="namespaces-values-none"]`).element.textContent; const element = wrapper.find(`[data-testid="namespaces-values-none"]`).element.textContent;
@ -60,7 +60,8 @@ describe('component: NamespaceFilter', () => {
options: () => [], options: () => [],
value: () => [{ label: text }], value: () => [{ label: text }],
}, },
directives: { shortkey: () => jest.fn() } directives: { shortkey: () => jest.fn() },
mocks: { $store: { getters: { 'i18n/t': () => text, namespaceFilterMode: () => undefined } } },
}); });
const element = wrapper.find(`[data-testid="namespaces-value-0"]`).element.textContent; const element = wrapper.find(`[data-testid="namespaces-value-0"]`).element.textContent;
@ -92,8 +93,9 @@ describe('component: NamespaceFilter', () => {
mocks: { mocks: {
$store: { $store: {
getters: { getters: {
'i18n/t': () => text, 'i18n/t': () => text,
'prefs/get': () => preferences 'prefs/get': () => preferences,
namespaceFilterMode: () => undefined,
}, },
} }
}, },
@ -114,6 +116,7 @@ describe('component: NamespaceFilter', () => {
options: () => [], options: () => [],
value: () => [], value: () => [],
}, },
mocks: { $store: { getters: { 'i18n/t': () => '', namespaceFilterMode: () => undefined } } },
directives: { shortkey: () => jest.fn() } directives: { shortkey: () => jest.fn() }
}); });
const dropdown = wrapper.find(`[data-testid="namespaces-dropdown"]`); const dropdown = wrapper.find(`[data-testid="namespaces-dropdown"]`);
@ -132,7 +135,7 @@ describe('component: NamespaceFilter', () => {
options: () => [], options: () => [],
value: () => [], value: () => [],
}, },
mocks: { $store: { getters: { 'i18n/t': () => text } } }, mocks: { $store: { getters: { 'i18n/t': () => text, namespaceFilterMode: () => undefined } } },
directives: { shortkey: () => jest.fn() } directives: { shortkey: () => jest.fn() }
}); });
const dropdown = wrapper.find(`[data-testid="namespaces-dropdown"]`); const dropdown = wrapper.find(`[data-testid="namespaces-dropdown"]`);
@ -147,18 +150,20 @@ describe('component: NamespaceFilter', () => {
const text = 'my option'; const text = 'my option';
const wrapper = mount(NamespaceFilter, { const wrapper = mount(NamespaceFilter, {
computed: { computed: {
filtered: () => [
{
kind: 'namespace',
label: `default-${ text }`,
},
],
options: () => [], options: () => [],
value: () => [], value: () => [],
}, },
mocks: { $store: { getters: { 'i18n/t': () => text } } }, mocks: { $store: { getters: { 'i18n/t': () => text, namespaceFilterMode: () => undefined } } },
directives: { shortkey: () => jest.fn() } directives: { shortkey: () => jest.fn() }
}); });
wrapper.vm.cachedFiltered = [
{
kind: 'namespace',
label: `default-${ text }`,
},
];
const dropdown = wrapper.find(`[data-testid="namespaces-dropdown"]`); const dropdown = wrapper.find(`[data-testid="namespaces-dropdown"]`);
await dropdown.trigger('click'); await dropdown.trigger('click');
@ -180,29 +185,31 @@ describe('component: NamespaceFilter', () => {
jest.spyOn(NamespaceFilter.computed.value, 'get').mockReturnValue([]); jest.spyOn(NamespaceFilter.computed.value, 'get').mockReturnValue([]);
const wrapper = mount(NamespaceFilter, { const wrapper = mount(NamespaceFilter, {
computed: { computed: {
filtered: () => [ options: () => [],
{ currentProduct: () => undefined,
label: text, namespaceFilterMode: () => undefined,
key, key: () => key,
elementId: text,
id: text,
kind: 'namespace',
enabled: true,
},
],
options: () => [],
currentProduct: () => undefined,
key: () => key,
}, },
mocks: { mocks: {
$store: { $store: {
getters: { 'i18n/t': () => text }, getters: { 'i18n/t': () => text, namespaceFilterMode: () => undefined },
dispatch: action dispatch: action
} }
}, },
directives: { shortkey: () => jest.fn() } directives: { shortkey: () => jest.fn() }
}); });
wrapper.vm.cachedFiltered = [
{
label: text,
key,
elementId: text,
id: text,
kind: 'namespace',
enabled: true,
},
];
await wrapper.find(`[data-testid="namespaces-dropdown"]`).trigger('click'); await wrapper.find(`[data-testid="namespaces-dropdown"]`).trigger('click');
await wrapper.find(`[data-testid="namespaces-option-0"]`).trigger('click'); await wrapper.find(`[data-testid="namespaces-option-0"]`).trigger('click');