Skip to content
代码片段 群组 项目
未验证 提交 63698463 编辑于 作者: Vitaly Slobodin's avatar Vitaly Slobodin 提交者: GitLab
浏览文件

Merge branch '435075-vue3-migration-dropdown_contents_create_view_spec' into 'master'

Removes spyon in dropdown_contents_create_view_spec

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139590



Merged-by: default avatarVitaly Slobodin <vslobodin@gitlab.com>
Approved-by: default avatarElwyn Benson <ebenson@gitlab.com>
Approved-by: default avatarVitaly Slobodin <vslobodin@gitlab.com>
Co-authored-by: default avatarArtur Fedorov <afedorov@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -14,13 +14,14 @@ Vue.use(Vuex); ...@@ -14,13 +14,14 @@ Vue.use(Vuex);
describe('DropdownContentsCreateView', () => { describe('DropdownContentsCreateView', () => {
let wrapper; let wrapper;
let store;
const colors = Object.keys(mockSuggestedColors).map((color) => ({ const colors = Object.keys(mockSuggestedColors).map((color) => ({
[color]: mockSuggestedColors[color], [color]: mockSuggestedColors[color],
})); }));
const createComponent = (initialState = mockConfig) => { const createComponent = (initialState = mockConfig) => {
const store = new Vuex.Store(labelSelectModule()); store = new Vuex.Store(labelSelectModule());
store.dispatch('setInitialState', initialState); store.dispatch('setInitialState', initialState);
wrapper = shallowMountExtended(DropdownContentsCreateView, { wrapper = shallowMountExtended(DropdownContentsCreateView, {
...@@ -47,7 +48,7 @@ describe('DropdownContentsCreateView', () => { ...@@ -47,7 +48,7 @@ describe('DropdownContentsCreateView', () => {
it('returns `true` when `labelCreateInProgress` is true', async () => { it('returns `true` when `labelCreateInProgress` is true', async () => {
await findColorSelectorInput().vm.$emit('input', '#ff0000'); await findColorSelectorInput().vm.$emit('input', '#ff0000');
await findLabelTitleInput().vm.$emit('input', 'Foo'); await findLabelTitleInput().vm.$emit('input', 'Foo');
wrapper.vm.$store.dispatch('requestCreateLabel'); store.dispatch('requestCreateLabel');
await nextTick(); await nextTick();
...@@ -81,7 +82,6 @@ describe('DropdownContentsCreateView', () => { ...@@ -81,7 +82,6 @@ describe('DropdownContentsCreateView', () => {
describe('getColorName', () => { describe('getColorName', () => {
it('returns color name from color object', () => { it('returns color name from color object', () => {
expect(findAllLinks().at(0).attributes('title')).toBe(Object.values(colors[0]).pop()); expect(findAllLinks().at(0).attributes('title')).toBe(Object.values(colors[0]).pop());
expect(wrapper.vm.getColorName(colors[0])).toBe(Object.values(colors[0]).pop());
}); });
}); });
...@@ -97,20 +97,17 @@ describe('DropdownContentsCreateView', () => { ...@@ -97,20 +97,17 @@ describe('DropdownContentsCreateView', () => {
describe('handleCreateClick', () => { describe('handleCreateClick', () => {
it('calls action `createLabel` with object containing `labelTitle` & `selectedColor`', async () => { it('calls action `createLabel` with object containing `labelTitle` & `selectedColor`', async () => {
jest.spyOn(wrapper.vm, 'createLabel').mockImplementation(); jest.spyOn(store, 'dispatch').mockImplementation();
await findColorSelectorInput().vm.$emit('input', '#ff0000'); await findColorSelectorInput().vm.$emit('input', '#ff0000');
await findLabelTitleInput().vm.$emit('input', 'Foo'); await findLabelTitleInput().vm.$emit('input', 'Foo');
findCreateClickButton().vm.$emit('click'); findCreateClickButton().vm.$emit('click');
await nextTick(); await nextTick();
expect(wrapper.vm.createLabel).toHaveBeenCalledWith( expect(store.dispatch).toHaveBeenCalledWith('createLabel', {
expect.objectContaining({ title: 'Foo',
title: 'Foo', color: '#ff0000',
color: '#ff0000', });
}),
);
}); });
}); });
}); });
...@@ -186,7 +183,7 @@ describe('DropdownContentsCreateView', () => { ...@@ -186,7 +183,7 @@ describe('DropdownContentsCreateView', () => {
}); });
it('shows gl-loading-icon within create button element when `labelCreateInProgress` is `true`', async () => { it('shows gl-loading-icon within create button element when `labelCreateInProgress` is `true`', async () => {
wrapper.vm.$store.dispatch('requestCreateLabel'); store.dispatch('requestCreateLabel');
await nextTick(); await nextTick();
const loadingIconEl = wrapper.find('.dropdown-actions').findComponent(GlLoadingIcon); const loadingIconEl = wrapper.find('.dropdown-actions').findComponent(GlLoadingIcon);
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册