Add pkg/harvester components + shell portings - 1

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia
2024-10-23 17:00:46 +02:00
parent f8408469f7
commit 4f2688f6ab
265 changed files with 42316 additions and 82 deletions
@@ -0,0 +1,41 @@
import { mount } from '@vue/test-utils';
import HarvesterEditNetwork from '../base.vue';
import { _EDIT } from '@shell/config/query-params';
describe('component: HarvesterEditNetwork', () => {
// eslint-disable-next-line jest/no-commented-out-tests
// it('should display all the inputs', () => {
// const wrapper = mount(HarvesterEditNetwork, { propsData: { mode: _EDIT } });
// const inputWraps = wrapper.findAll('[data-testid^=input-hen-]');
// expect(inputWraps).toHaveLength(5);
// });
it.each([
'name',
])('should emit an update on %p input', (field) => {
const wrapper = mount(HarvesterEditNetwork, { propsData: { mode: _EDIT } });
const input = wrapper.find(`[data-testid="input-hen-${ field }"]`).find('input');
const newValue = 123;
input.setValue(newValue);
expect(wrapper.emitted('update')).toHaveLength(1);
});
it.each([
'model',
'networkName',
'type',
])('should emit an update on %p selection change', async(field) => {
const wrapper = mount(HarvesterEditNetwork, { propsData: { mode: _EDIT } });
const select = wrapper.find(`[data-testid="input-hen-${ field }"]`);
select.find('button').trigger('click');
await wrapper.trigger('keydown.down');
await wrapper.trigger('keydown.enter');
expect(wrapper.emitted('update')).toHaveLength(1);
});
});