2021-01-03 14:25:43 +05:30
|
|
|
import { GlFormTextarea } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
2021-01-03 14:25:43 +05:30
|
|
|
import UsersWithId from '~/feature_flags/components/strategies/users_with_id.vue';
|
|
|
|
import { usersWithIdStrategy } from '../../mock_data';
|
|
|
|
|
|
|
|
const DEFAULT_PROPS = {
|
|
|
|
strategy: usersWithIdStrategy,
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('~/feature_flags/components/users_with_id.vue', () => {
|
|
|
|
let wrapper;
|
|
|
|
let textarea;
|
|
|
|
|
|
|
|
const factory = (props = {}) => mount(UsersWithId, { propsData: { ...DEFAULT_PROPS, ...props } });
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = factory();
|
|
|
|
textarea = wrapper.find(GlFormTextarea);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
if (wrapper?.destroy) {
|
|
|
|
wrapper.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should display the current value of the parameters', () => {
|
|
|
|
expect(textarea.element.value).toBe(usersWithIdStrategy.parameters.userIds);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should emit a change event when the IDs change', () => {
|
|
|
|
textarea.setValue('4,5,6');
|
|
|
|
|
|
|
|
expect(wrapper.emitted('change')).toEqual([[{ parameters: { userIds: '4,5,6' } }]]);
|
|
|
|
});
|
|
|
|
});
|