diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 09:08:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 09:08:11 +0000 |
commit | 1f5a2543e4daf21dd98d8ff0514781c403445c81 (patch) | |
tree | 22af0594a5de457ffb346c2259f9d30c3fd5479f /spec/frontend/ide/commit_icon_spec.js | |
parent | 9bded6fb2268204757c35540fadef8e1b6351249 (diff) | |
download | gitlab-ce-1f5a2543e4daf21dd98d8ff0514781c403445c81.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/commit_icon_spec.js')
-rw-r--r-- | spec/frontend/ide/commit_icon_spec.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/frontend/ide/commit_icon_spec.js b/spec/frontend/ide/commit_icon_spec.js new file mode 100644 index 00000000000..90b8e34497c --- /dev/null +++ b/spec/frontend/ide/commit_icon_spec.js @@ -0,0 +1,45 @@ +import { commitItemIconMap } from '~/ide/constants'; +import { decorateData } from '~/ide/stores/utils'; +import getCommitIconMap from '~/ide/commit_icon'; + +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); + }); +}); |