Commit 6aa21d72 authored by Fernando's avatar Fernando

Code reviewe changes

* Add additional unit tests for props
* Add additional unit tests for emitted events
parent a5180ac3
...@@ -27,8 +27,8 @@ export default { ...@@ -27,8 +27,8 @@ export default {
}, },
}, },
methods: { methods: {
onToggle(value) { onToggle(enabled) {
const entity = { ...this.entity, enabled: value }; const entity = { ...this.entity, enabled };
this.$emit('input', entity); this.$emit('input', entity);
}, },
onConfigurationUpdate(configuration) { onConfigurationUpdate(configuration) {
......
...@@ -21,6 +21,7 @@ describe('AnalyzerConfiguration component', () => { ...@@ -21,6 +21,7 @@ describe('AnalyzerConfiguration component', () => {
}; };
const findInputElement = () => wrapper.find('input[type="checkbox"]'); const findInputElement = () => wrapper.find('input[type="checkbox"]');
const findDynamicFields = () => wrapper.find(DynamicFields);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
...@@ -77,7 +78,7 @@ describe('AnalyzerConfiguration component', () => { ...@@ -77,7 +78,7 @@ describe('AnalyzerConfiguration component', () => {
}); });
it('does not render the nested dynamic forms', () => { it('does not render the nested dynamic forms', () => {
expect(wrapper.find(DynamicFields).exists()).toBe(false); expect(findDynamicFields().exists()).toBe(false);
}); });
}); });
...@@ -104,11 +105,22 @@ describe('AnalyzerConfiguration component', () => { ...@@ -104,11 +105,22 @@ describe('AnalyzerConfiguration component', () => {
}); });
it('it renders the nested dynamic forms', () => { it('it renders the nested dynamic forms', () => {
expect(wrapper.find(DynamicFields).exists()).toBe(true); expect(findDynamicFields().exists()).toBe(true);
});
it('it emits an input event when dynamic form fields emits an input event', () => {
findDynamicFields().vm.$emit('input', analyzerEntity.configuration);
const [[payload]] = wrapper.emitted('input');
expect(payload).toEqual(analyzerEntity);
}); });
it('passes the disabled prop to dynamic fields component', () => { it('passes the disabled prop to dynamic fields component', () => {
expect(wrapper.find(DynamicFields).vm.$attrs.disabled).toBe(!analyzerEntity.enabled); expect(findDynamicFields().vm.$attrs.disabled).toBe(!analyzerEntity.enabled);
});
it('passes the entities prop to the dynamic fields component', () => {
expect(findDynamicFields().props('entities')).toBe(analyzerEntity.configuration);
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment