Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/ide/stores/getters_spec.js
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/ide/stores/getters_spec.js')
-rw-r--r--spec/frontend/ide/stores/getters_spec.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/spec/frontend/ide/stores/getters_spec.js b/spec/frontend/ide/stores/getters_spec.js
index 408ea2b2939..dcf05329ce0 100644
--- a/spec/frontend/ide/stores/getters_spec.js
+++ b/spec/frontend/ide/stores/getters_spec.js
@@ -417,4 +417,69 @@ describe('IDE store getters', () => {
expect(localStore.getters[getterName]).toBe(val);
});
});
+
+ describe('entryExists', () => {
+ beforeEach(() => {
+ localState.entries = {
+ foo: file('foo', 'foo', 'tree'),
+ 'foo/bar.png': file(),
+ };
+ });
+
+ it.each`
+ path | deleted | value
+ ${'foo/bar.png'} | ${false} | ${true}
+ ${'foo/bar.png'} | ${true} | ${false}
+ ${'foo'} | ${false} | ${true}
+ `(
+ 'returns $value for an existing entry path: $path (deleted: $deleted)',
+ ({ path, deleted, value }) => {
+ localState.entries[path].deleted = deleted;
+
+ expect(localStore.getters.entryExists(path)).toBe(value);
+ },
+ );
+
+ it('returns false for a non existing entry path', () => {
+ expect(localStore.getters.entryExists('bar.baz')).toBe(false);
+ });
+ });
+
+ describe('getAvailableFileName', () => {
+ it.each`
+ path | newPath
+ ${'foo'} | ${'foo_1'}
+ ${'foo__93.png'} | ${'foo__94.png'}
+ ${'foo/bar.png'} | ${'foo/bar_1.png'}
+ ${'foo/bar--34.png'} | ${'foo/bar--35.png'}
+ ${'foo/bar 2.png'} | ${'foo/bar 3.png'}
+ ${'foo/bar-621.png'} | ${'foo/bar-622.png'}
+ ${'jquery.min.js'} | ${'jquery_1.min.js'}
+ ${'my_spec_22.js.snap'} | ${'my_spec_23.js.snap'}
+ ${'subtitles5.mp4.srt'} | ${'subtitles_6.mp4.srt'}
+ ${'sample_file.mp3'} | ${'sample_file_1.mp3'}
+ ${'Screenshot 2020-05-26 at 10.53.08 PM.png'} | ${'Screenshot 2020-05-26 at 11.53.08 PM.png'}
+ `('suffixes the path with a number if the path already exists', ({ path, newPath }) => {
+ localState.entries[path] = file();
+
+ expect(localStore.getters.getAvailableFileName(path)).toBe(newPath);
+ });
+
+ it('loops through all incremented entries and keeps trying until a file path that does not exist is found', () => {
+ localState.entries = {
+ 'bar/baz_1.png': file(),
+ 'bar/baz_2.png': file(),
+ 'bar/baz_3.png': file(),
+ 'bar/baz_4.png': file(),
+ 'bar/baz_5.png': file(),
+ 'bar/baz_72.png': file(),
+ };
+
+ expect(localStore.getters.getAvailableFileName('bar/baz_1.png')).toBe('bar/baz_6.png');
+ });
+
+ it('returns the entry path as is if the path does not exist', () => {
+ expect(localStore.getters.getAvailableFileName('foo-bar1.jpg')).toBe('foo-bar1.jpg');
+ });
+ });
});