diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/frontend/ide/stores/actions/tree_spec.js | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/frontend/ide/stores/actions/tree_spec.js')
-rw-r--r-- | spec/frontend/ide/stores/actions/tree_spec.js | 92 |
1 files changed, 38 insertions, 54 deletions
diff --git a/spec/frontend/ide/stores/actions/tree_spec.js b/spec/frontend/ide/stores/actions/tree_spec.js index 8d7328725e9..fc44cbb21ae 100644 --- a/spec/frontend/ide/stores/actions/tree_spec.js +++ b/spec/frontend/ide/stores/actions/tree_spec.js @@ -62,27 +62,21 @@ describe('Multi-file store tree actions', () => { }); }); - it('adds data into tree', (done) => { - store - .dispatch('getFiles', basicCallParameters) - .then(() => { - projectTree = store.state.trees['abcproject/main']; - - expect(projectTree.tree.length).toBe(2); - expect(projectTree.tree[0].type).toBe('tree'); - expect(projectTree.tree[0].tree[1].name).toBe('fileinfolder.js'); - expect(projectTree.tree[1].type).toBe('blob'); - expect(projectTree.tree[0].tree[0].tree[0].type).toBe('blob'); - expect(projectTree.tree[0].tree[0].tree[0].name).toBe('fileinsubfolder.js'); - - done(); - }) - .catch(done.fail); + it('adds data into tree', async () => { + await store.dispatch('getFiles', basicCallParameters); + projectTree = store.state.trees['abcproject/main']; + + expect(projectTree.tree.length).toBe(2); + expect(projectTree.tree[0].type).toBe('tree'); + expect(projectTree.tree[0].tree[1].name).toBe('fileinfolder.js'); + expect(projectTree.tree[1].type).toBe('blob'); + expect(projectTree.tree[0].tree[0].tree[0].type).toBe('blob'); + expect(projectTree.tree[0].tree[0].tree[0].name).toBe('fileinsubfolder.js'); }); }); describe('error', () => { - it('dispatches error action', (done) => { + it('dispatches error action', async () => { const dispatch = jest.fn(); store.state.projects = { @@ -103,28 +97,26 @@ describe('Multi-file store tree actions', () => { mock.onGet(/(.*)/).replyOnce(500); - getFiles( - { - commit() {}, - dispatch, - state: store.state, - getters, - }, - { - projectId: 'abc/def', - branchId: 'main-testing', - }, - ) - .then(done.fail) - .catch(() => { - expect(dispatch).toHaveBeenCalledWith('setErrorMessage', { - text: 'An error occurred while loading all the files.', - action: expect.any(Function), - actionText: 'Please try again', - actionPayload: { projectId: 'abc/def', branchId: 'main-testing' }, - }); - done(); - }); + await expect( + getFiles( + { + commit() {}, + dispatch, + state: store.state, + getters, + }, + { + projectId: 'abc/def', + branchId: 'main-testing', + }, + ), + ).rejects.toEqual(new Error('Request failed with status code 500')); + expect(dispatch).toHaveBeenCalledWith('setErrorMessage', { + text: 'An error occurred while loading all the files.', + action: expect.any(Function), + actionText: 'Please try again', + actionPayload: { projectId: 'abc/def', branchId: 'main-testing' }, + }); }); }); }); @@ -137,15 +129,9 @@ describe('Multi-file store tree actions', () => { store.state.entries[tree.path] = tree; }); - it('toggles the tree open', (done) => { - store - .dispatch('toggleTreeOpen', tree.path) - .then(() => { - expect(tree.opened).toBeTruthy(); - - done(); - }) - .catch(done.fail); + it('toggles the tree open', async () => { + await store.dispatch('toggleTreeOpen', tree.path); + expect(tree.opened).toBeTruthy(); }); }); @@ -163,24 +149,23 @@ describe('Multi-file store tree actions', () => { Object.assign(store.state.entries, createEntriesFromPaths(paths)); }); - it('opens the parents', (done) => { - testAction( + it('opens the parents', () => { + return testAction( showTreeEntry, 'grandparent/parent/child.txt', store.state, [{ type: types.SET_TREE_OPEN, payload: 'grandparent/parent' }], [{ type: 'showTreeEntry', payload: 'grandparent/parent' }], - done, ); }); }); describe('setDirectoryData', () => { - it('sets tree correctly if there are no opened files yet', (done) => { + it('sets tree correctly if there are no opened files yet', () => { const treeFile = file({ name: 'README.md' }); store.state.trees['abcproject/main'] = {}; - testAction( + return testAction( setDirectoryData, { projectId: 'abcproject', branchId: 'main', treeList: [treeFile] }, store.state, @@ -201,7 +186,6 @@ describe('Multi-file store tree actions', () => { }, ], [], - done, ); }); }); |