diff options
author | Denys Mishunov <dmishunov@gitlab.com> | 2019-06-26 17:50:31 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-06-26 17:50:31 +0300 |
commit | f0fc53589755d00320b8c12ae739ba6c18872c3c (patch) | |
tree | 5fffcfa518cb76e34c3debbbcb19d275dcc9f4fc /spec/frontend/ide | |
parent | 4b7f053a49168491215e8ee20060c7283e138858 (diff) |
Re-name entries in one commit
Update window's URL after entry's re-name
Set proper hook for correct fileLanguage
Filtered out `moved` entries from the tree
Diffstat (limited to 'spec/frontend/ide')
-rw-r--r-- | spec/frontend/ide/utils_spec.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/frontend/ide/utils_spec.js b/spec/frontend/ide/utils_spec.js new file mode 100644 index 00000000000..2b7dffdcd88 --- /dev/null +++ b/spec/frontend/ide/utils_spec.js @@ -0,0 +1,44 @@ +import { commitItemIconMap } from '~/ide/constants'; +import { getCommitIconMap } from '~/ide/utils'; +import { decorateData } from '~/ide/stores/utils'; + +describe('WebIDE utils', () => { + const createFile = (name = 'name', id = name, type = '', parent = null) => + decorateData({ + id, + type, + icon: 'icon', + url: 'url', + name, + path: parent ? `${parent.path}/${name}` : name, + parentPath: parent ? parent.path : '', + lastCommit: {}, + }); + + describe('getCommitIconMap', () => { + let entry; + + beforeEach(() => { + entry = createFile('Entry item'); + }); + + it('renders "deleted" icon for deleted entries', () => { + entry.deleted = true; + expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.deleted); + }); + it('renders "addition" icon for temp entries', () => { + entry.tempFile = true; + expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.addition); + }); + it('renders "modified" icon for newly-renamed entries', () => { + entry.prevPath = 'foo/bar'; + entry.tempFile = false; + expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.modified); + }); + it('renders "modified" icon even for temp entries if they are newly-renamed', () => { + entry.prevPath = 'foo/bar'; + entry.tempFile = true; + expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.modified); + }); + }); +}); |