Commit d7123410 authored by Savas Vedova's avatar Savas Vedova

Fix broken tests

parent 903a5fee
import { GlDropdown } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import VulnerabilityStateDropdown from 'ee/vulnerabilities/components/vulnerability_state_dropdown.vue';
import { VULNERABILITY_STATE_OBJECTS } from 'ee/vulnerabilities/constants';
......@@ -11,6 +12,9 @@ describe('Vulnerability state dropdown component', () => {
// Create a dropdown that by default has the first vulnerability state selected.
wrapper = shallowMount(VulnerabilityStateDropdown, {
propsData: { initialState },
stubs: {
GlDropdown,
},
});
// Mock out this function, it's called by some methods in the component.
......@@ -136,13 +140,13 @@ describe('Vulnerability state dropdown component', () => {
});
});
it('when the parent component changes the state, the dropdown will update its selected and initial item', () => {
it('when the parent component changes the state, the dropdown will update its selected and initial item', async () => {
const [stateString, stateObject] = vulnerabilityStateEntries[1];
wrapper.setProps({ initialState: stateString }); // Change the state.
return wrapper.vm.$nextTick().then(() => {
expect(innerDropdown().attributes('text')).toBe(stateString); // Check that the dropdown button's value matches the initial state.
expect(innerDropdown().props('text')).toBe(stateString); // Check that the dropdown button's value matches the initial state.
expect(selectedItem().text()).toMatch(new RegExp(`^${stateObject.action}`, 'i')); // Check that the selected item is the initial state.
expect(isDisabled(saveButton())).toBe(true); // Check that the save button is disabled.
});
......
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