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-10-14 21:08:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-14 21:08:47 +0300
commit93960490b8bdbc0f2ab1d102b83ec5d5b87c97a6 (patch)
tree05e12b8fc3094f8de548aff4f929ef3433a3f52e /spec/frontend/ide
parent99670fc6a027caee34a6537c8def2e998d1ac5c2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide')
-rw-r--r--spec/frontend/ide/components/new_dropdown/upload_spec.js17
-rw-r--r--spec/frontend/ide/stores/actions/file_spec.js14
-rw-r--r--spec/frontend/ide/stores/mutations/file_spec.js26
-rw-r--r--spec/frontend/ide/stores/utils_spec.js10
4 files changed, 47 insertions, 20 deletions
diff --git a/spec/frontend/ide/components/new_dropdown/upload_spec.js b/spec/frontend/ide/components/new_dropdown/upload_spec.js
index ae497106f73..3f3784dbb3a 100644
--- a/spec/frontend/ide/components/new_dropdown/upload_spec.js
+++ b/spec/frontend/ide/components/new_dropdown/upload_spec.js
@@ -59,14 +59,11 @@ describe('new dropdown upload', () => {
result: 'base64,cGxhaW4gdGV4dA==',
};
const binaryTarget = {
- result: 'base64,w4I=',
+ result: 'base64,8PDw8A==', // ðððð
};
- const textFile = new File(['plain text'], 'textFile');
- const binaryFile = {
- name: 'binaryFile',
- type: 'image/png',
- };
+ const textFile = new File(['plain text'], 'textFile');
+ const binaryFile = new File(['😺'], 'binaryFile');
beforeEach(() => {
jest.spyOn(FileReader.prototype, 'readAsText');
@@ -92,16 +89,16 @@ describe('new dropdown upload', () => {
.catch(done.fail);
});
- it('splits content on base64 if binary', () => {
+ it('creates a blob URL for the content if binary', () => {
vm.createFile(binaryTarget, binaryFile);
- expect(FileReader.prototype.readAsText).not.toHaveBeenCalledWith(textFile);
+ expect(FileReader.prototype.readAsText).not.toHaveBeenCalled();
expect(vm.$emit).toHaveBeenCalledWith('create', {
name: binaryFile.name,
type: 'blob',
- content: binaryTarget.result.split('base64,')[1],
- rawPath: binaryTarget.result,
+ content: 'ðððð',
+ rawPath: 'blob:https://gitlab.com/048c7ac1-98de-4a37-ab1b-0206d0ea7e1b',
});
});
});
diff --git a/spec/frontend/ide/stores/actions/file_spec.js b/spec/frontend/ide/stores/actions/file_spec.js
index 974c0715c06..8f7fcc25cf0 100644
--- a/spec/frontend/ide/stores/actions/file_spec.js
+++ b/spec/frontend/ide/stores/actions/file_spec.js
@@ -291,6 +291,20 @@ describe('IDE store file actions', () => {
expect(store.state.openFiles[0].name).toBe(localFile.name);
});
});
+
+ it('does not toggle loading if toggleLoading=false', () => {
+ expect(localFile.loading).toBe(false);
+
+ return store
+ .dispatch('getFileData', {
+ path: localFile.path,
+ makeFileActive: false,
+ toggleLoading: false,
+ })
+ .then(() => {
+ expect(localFile.loading).toBe(true);
+ });
+ });
});
describe('Re-named success', () => {
diff --git a/spec/frontend/ide/stores/mutations/file_spec.js b/spec/frontend/ide/stores/mutations/file_spec.js
index b53e40be980..d303de6e9ef 100644
--- a/spec/frontend/ide/stores/mutations/file_spec.js
+++ b/spec/frontend/ide/stores/mutations/file_spec.js
@@ -39,20 +39,34 @@ describe('IDE store file mutations', () => {
});
describe('TOGGLE_FILE_OPEN', () => {
- beforeEach(() => {
+ it('adds into opened files', () => {
mutations.TOGGLE_FILE_OPEN(localState, localFile.path);
- });
- it('adds into opened files', () => {
expect(localFile.opened).toBeTruthy();
expect(localState.openFiles.length).toBe(1);
});
- it('removes from opened files', () => {
+ describe('if already open', () => {
+ it('removes from opened files', () => {
+ mutations.TOGGLE_FILE_OPEN(localState, localFile.path);
+ mutations.TOGGLE_FILE_OPEN(localState, localFile.path);
+
+ expect(localFile.opened).toBeFalsy();
+ expect(localState.openFiles.length).toBe(0);
+ });
+ });
+
+ it.each`
+ entry | loading
+ ${{ opened: false }} | ${true}
+ ${{ opened: false, tempFile: true }} | ${false}
+ ${{ opened: true }} | ${false}
+ `('for state: $entry, sets loading=$loading', ({ entry, loading }) => {
+ Object.assign(localFile, entry);
+
mutations.TOGGLE_FILE_OPEN(localState, localFile.path);
- expect(localFile.opened).toBeFalsy();
- expect(localState.openFiles.length).toBe(0);
+ expect(localFile.loading).toBe(loading);
});
});
diff --git a/spec/frontend/ide/stores/utils_spec.js b/spec/frontend/ide/stores/utils_spec.js
index d1eb4304c79..b185013050e 100644
--- a/spec/frontend/ide/stores/utils_spec.js
+++ b/spec/frontend/ide/stores/utils_spec.js
@@ -46,7 +46,7 @@ describe('Multi-file store utils', () => {
path: 'added',
tempFile: true,
content: 'new file content',
- rawPath: 'data:image/png;base64,abc',
+ rawPath: 'blob:https://gitlab.com/048c7ac1-98de-4a37-ab1b-0206d0ea7e1b',
lastCommitSha: '123456789',
},
{ ...file('deletedFile'), path: 'deletedFile', deleted: true },
@@ -77,7 +77,8 @@ describe('Multi-file store utils', () => {
{
action: commitActionTypes.create,
file_path: 'added',
- content: 'new file content',
+ // atob("new file content")
+ content: 'bmV3IGZpbGUgY29udGVudA==',
encoding: 'base64',
last_commit_id: '123456789',
previous_path: undefined,
@@ -117,7 +118,7 @@ describe('Multi-file store utils', () => {
path: 'added',
tempFile: true,
content: 'new file content',
- rawPath: 'data:image/png;base64,abc',
+ rawPath: 'blob:https://gitlab.com/048c7ac1-98de-4a37-ab1b-0206d0ea7e1b',
lastCommitSha: '123456789',
},
],
@@ -148,7 +149,8 @@ describe('Multi-file store utils', () => {
{
action: commitActionTypes.create,
file_path: 'added',
- content: 'new file content',
+ // atob("new file content")
+ content: 'bmV3IGZpbGUgY29udGVudA==',
encoding: 'base64',
last_commit_id: '123456789',
previous_path: undefined,