summaryrefslogtreecommitdiff
path: root/spec/frontend/ide/lib
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/frontend/ide/lib
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/frontend/ide/lib')
-rw-r--r--spec/frontend/ide/lib/common/model_spec.js2
-rw-r--r--spec/frontend/ide/lib/create_diff_spec.js8
-rw-r--r--spec/frontend/ide/lib/create_file_diff_spec.js14
-rw-r--r--spec/frontend/ide/lib/diff/controller_spec.js4
-rw-r--r--spec/frontend/ide/lib/editor_spec.js2
-rw-r--r--spec/frontend/ide/lib/editorconfig/parser_spec.js6
-rw-r--r--spec/frontend/ide/lib/errors_spec.js2
-rw-r--r--spec/frontend/ide/lib/files_spec.js11
-rw-r--r--spec/frontend/ide/lib/languages/hcl_spec.js36
-rw-r--r--spec/frontend/ide/lib/mirror_spec.js4
10 files changed, 62 insertions, 27 deletions
diff --git a/spec/frontend/ide/lib/common/model_spec.js b/spec/frontend/ide/lib/common/model_spec.js
index df46b7774b0..51df1e2e42f 100644
--- a/spec/frontend/ide/lib/common/model_spec.js
+++ b/spec/frontend/ide/lib/common/model_spec.js
@@ -81,7 +81,7 @@ describe('Multi-file editor library model', () => {
});
describe('onChange', () => {
- it('calls callback on change', done => {
+ it('calls callback on change', (done) => {
const spy = jest.fn();
model.onChange(spy);
diff --git a/spec/frontend/ide/lib/create_diff_spec.js b/spec/frontend/ide/lib/create_diff_spec.js
index 273f9ee27bd..76494f9af1b 100644
--- a/spec/frontend/ide/lib/create_diff_spec.js
+++ b/spec/frontend/ide/lib/create_diff_spec.js
@@ -145,12 +145,12 @@ new file mode 100644
--- /dev/null
+++ b/${PATH_LOREM}
@@ -0,0 +1,${LINES.length} @@
-${LINES.map(line => `+${line}`).join('\n')}
+${LINES.map((line) => `+${line}`).join('\n')}
diff --git "a/${PATH_IPSUM}" "b/${PATH_IPSUM}"
--- a/${PATH_IPSUM}
+++ b/${PATH_IPSUM}
@@ -1,${LINES.length} +1,1 @@
-${LINES.map(line => `-${line}`).join('\n')}
+${LINES.map((line) => `-${line}`).join('\n')}
+That's all folks!
\\ No newline at end of file
`;
@@ -167,10 +167,10 @@ ${LINES.map(line => `-${line}`).join('\n')}
const deletedFiles = ['foo/bar/zed/test.md', 'foo/bar/zed/test2.md'];
const entries = deletedFiles.reduce((acc, path) => Object.assign(acc, createEntries(path)), {});
const allDeleted = [...deletedFiles, 'foo/bar/zed', 'foo/bar'];
- allDeleted.forEach(path => {
+ allDeleted.forEach((path) => {
entries[path].deleted = true;
});
- const changedFiles = deletedFiles.map(x => entries[x]);
+ const changedFiles = deletedFiles.map((x) => entries[x]);
const result = createDiff({ changedFiles, entries });
diff --git a/spec/frontend/ide/lib/create_file_diff_spec.js b/spec/frontend/ide/lib/create_file_diff_spec.js
index 4b428468a6d..294f0a926aa 100644
--- a/spec/frontend/ide/lib/create_file_diff_spec.js
+++ b/spec/frontend/ide/lib/create_file_diff_spec.js
@@ -21,11 +21,7 @@ const spliceLines = (content, lineNumber, deleteCount = 0, newLines = []) => {
return lines.join('\n');
};
-const mapLines = (content, mapFn) =>
- content
- .split('\n')
- .map(mapFn)
- .join('\n');
+const mapLines = (content, mapFn) => content.split('\n').map(mapFn).join('\n');
describe('IDE lib/create_file_diff', () => {
it('returns empty string with "garbage" action', () => {
@@ -55,7 +51,7 @@ describe('IDE lib/create_file_diff', () => {
const expectedHead = `diff --git "a/${PATH}" "b/${PATH}"
new file mode 100644`;
- const expectedChunkHead = lineCount => `--- /dev/null
+ const expectedChunkHead = (lineCount) => `--- /dev/null
+++ b/${PATH}
@@ -0,0 +1,${lineCount} @@`;
@@ -90,7 +86,7 @@ ${expectedChunkHead(1)}
expect(result).toBe(`${expectedHead}
${expectedChunkHead(TEXT_LINE_COUNT)}
-${mapLines(TEXT, line => `+${line}`)}
+${mapLines(TEXT, (line) => `+${line}`)}
`);
});
});
@@ -99,7 +95,7 @@ ${mapLines(TEXT, line => `+${line}`)}
const expectedHead = `diff --git "a/${PATH}" "b/${PATH}"
deleted file mode 100644`;
- const expectedChunkHead = lineCount => `--- a/${PATH}
+ const expectedChunkHead = (lineCount) => `--- a/${PATH}
+++ /dev/null
@@ -1,${lineCount} +0,0 @@`;
@@ -115,7 +111,7 @@ deleted file mode 100644`;
expect(result).toBe(`${expectedHead}
${expectedChunkHead(TEXT_LINE_COUNT)}
-${mapLines(TEXT, line => `-${line}`)}
+${mapLines(TEXT, (line) => `-${line}`)}
`);
});
});
diff --git a/spec/frontend/ide/lib/diff/controller_spec.js b/spec/frontend/ide/lib/diff/controller_spec.js
index 8ee6388a760..57c134620c0 100644
--- a/spec/frontend/ide/lib/diff/controller_spec.js
+++ b/spec/frontend/ide/lib/diff/controller_spec.js
@@ -37,7 +37,7 @@ describe('Multi-file editor library dirty diff controller', () => {
});
describe('getDiffChangeType', () => {
- ['added', 'removed', 'modified'].forEach(type => {
+ ['added', 'removed', 'modified'].forEach((type) => {
it(`returns ${type}`, () => {
const change = {
[type]: true,
@@ -49,7 +49,7 @@ describe('Multi-file editor library dirty diff controller', () => {
});
describe('getDecorator', () => {
- ['added', 'removed', 'modified'].forEach(type => {
+ ['added', 'removed', 'modified'].forEach((type) => {
it(`returns with linesDecorationsClassName for ${type}`, () => {
const change = {
[type]: true,
diff --git a/spec/frontend/ide/lib/editor_spec.js b/spec/frontend/ide/lib/editor_spec.js
index 01c2eab33a5..12779c61dc3 100644
--- a/spec/frontend/ide/lib/editor_spec.js
+++ b/spec/frontend/ide/lib/editor_spec.js
@@ -15,7 +15,7 @@ describe('Multi-file editor library', () => {
let holder;
let store;
- const setNodeOffsetWidth = val => {
+ const setNodeOffsetWidth = (val) => {
Object.defineProperty(instance.instance.getDomNode(), 'offsetWidth', {
get() {
return val;
diff --git a/spec/frontend/ide/lib/editorconfig/parser_spec.js b/spec/frontend/ide/lib/editorconfig/parser_spec.js
index f99410236e1..c2b4a8e6c49 100644
--- a/spec/frontend/ide/lib/editorconfig/parser_spec.js
+++ b/spec/frontend/ide/lib/editorconfig/parser_spec.js
@@ -2,14 +2,14 @@ import { getRulesWithTraversal } from '~/ide/lib/editorconfig/parser';
import { exampleConfigs, exampleFiles } from './mock_data';
describe('~/ide/lib/editorconfig/parser', () => {
- const getExampleConfigContent = path =>
- Promise.resolve(exampleConfigs.find(x => x.path === path)?.content);
+ const getExampleConfigContent = (path) =>
+ Promise.resolve(exampleConfigs.find((x) => x.path === path)?.content);
describe('getRulesWithTraversal', () => {
it.each(exampleFiles)(
'traverses through all editorconfig files in parent directories (until root=true is hit) and finds rules for this file (case %#)',
({ path, rules }) => {
- return getRulesWithTraversal(path, getExampleConfigContent).then(result => {
+ return getRulesWithTraversal(path, getExampleConfigContent).then((result) => {
expect(result).toEqual(rules);
});
},
diff --git a/spec/frontend/ide/lib/errors_spec.js b/spec/frontend/ide/lib/errors_spec.js
index 733d5a5da3c..2e4acdb8a63 100644
--- a/spec/frontend/ide/lib/errors_spec.js
+++ b/spec/frontend/ide/lib/errors_spec.js
@@ -14,7 +14,7 @@ const CODEOWNERS_MESSAGE =
const CHANGED_MESSAGE = 'Things changed since you started editing';
describe('~/ide/lib/errors', () => {
- const createResponseError = message => ({
+ const createResponseError = (message) => ({
response: {
data: {
message,
diff --git a/spec/frontend/ide/lib/files_spec.js b/spec/frontend/ide/lib/files_spec.js
index 8ca6f01d9a6..50738af0e33 100644
--- a/spec/frontend/ide/lib/files_spec.js
+++ b/spec/frontend/ide/lib/files_spec.js
@@ -1,7 +1,9 @@
import { decorateFiles, splitParent } from '~/ide/lib/files';
import { decorateData } from '~/ide/stores/utils';
-const createEntries = paths => {
+const TEST_BLOB_DATA = { mimeType: 'test/mime' };
+
+const createEntries = (paths) => {
const createEntry = (acc, { path, type, children }) => {
const { name, parent } = splitParent(path);
@@ -13,7 +15,8 @@ const createEntries = paths => {
type,
parentPath: parent,
}),
- tree: children.map(childName => expect.objectContaining({ name: childName })),
+ tree: children.map((childName) => expect.objectContaining({ name: childName })),
+ ...(type === 'blob' ? TEST_BLOB_DATA : {}),
};
return acc;
@@ -43,14 +46,14 @@ describe('IDE lib decorate files', () => {
{ path: 'README.md', type: 'blob', children: [] },
]);
- const { entries, treeList } = decorateFiles({ data });
+ const { entries, treeList } = decorateFiles({ data, blobData: TEST_BLOB_DATA });
// Here we test the keys and then each key/value individually because `expect(entries).toEqual(expectedEntries)`
// was taking a very long time for some reason. Probably due to large objects and nested `expect.objectContaining`.
const entryKeys = Object.keys(entries);
expect(entryKeys).toEqual(Object.keys(expectedEntries));
- entryKeys.forEach(key => {
+ entryKeys.forEach((key) => {
expect(entries[key]).toEqual(expectedEntries[key]);
});
diff --git a/spec/frontend/ide/lib/languages/hcl_spec.js b/spec/frontend/ide/lib/languages/hcl_spec.js
index a39673a3225..c6ebad6a4f4 100644
--- a/spec/frontend/ide/lib/languages/hcl_spec.js
+++ b/spec/frontend/ide/lib/languages/hcl_spec.js
@@ -284,6 +284,42 @@ describe('tokenization for .tf files', () => {
],
],
],
+ [
+ ` foo = <<-EOF
+ bar
+ EOF`,
+ [
+ [
+ { language: 'hcl', offset: 0, type: '' },
+ { language: 'hcl', offset: 2, type: 'variable.hcl' },
+ { language: 'hcl', offset: 5, type: '' },
+ { language: 'hcl', offset: 6, type: 'operator.hcl' },
+ { language: 'hcl', offset: 7, type: '' },
+ { language: 'hcl', offset: 8, type: 'string.heredoc.delimiter.hcl' },
+ ],
+ [{ language: 'hcl', offset: 0, type: 'string.heredoc.hcl' }],
+ [
+ { language: 'hcl', offset: 0, type: 'string.heredoc.hcl' },
+ { language: 'hcl', offset: 2, type: 'string.heredoc.delimiter.hcl' },
+ ],
+ ],
+ ],
+ [
+ `foo = <<-EOF
+bar
+EOF`,
+ [
+ [
+ { language: 'hcl', offset: 0, type: 'variable.hcl' },
+ { language: 'hcl', offset: 3, type: '' },
+ { language: 'hcl', offset: 4, type: 'operator.hcl' },
+ { language: 'hcl', offset: 5, type: '' },
+ { language: 'hcl', offset: 6, type: 'string.heredoc.delimiter.hcl' },
+ ],
+ [{ language: 'hcl', offset: 0, type: 'string.heredoc.hcl' }],
+ [{ language: 'hcl', offset: 0, type: 'string.heredoc.delimiter.hcl' }],
+ ],
+ ],
])('%s', (string, tokens) => {
expect(editor.tokenize(string, 'hcl')).toEqual(tokens);
});
diff --git a/spec/frontend/ide/lib/mirror_spec.js b/spec/frontend/ide/lib/mirror_spec.js
index 21bed5948f3..8f417ea54dc 100644
--- a/spec/frontend/ide/lib/mirror_spec.js
+++ b/spec/frontend/ide/lib/mirror_spec.js
@@ -72,7 +72,7 @@ describe('ide/lib/mirror', () => {
});
const waitForConnection = (delay = SERVICE_DELAY) => {
- const wait = new Promise(resolve => {
+ const wait = new Promise((resolve) => {
setTimeout(resolve, 10);
});
@@ -82,7 +82,7 @@ describe('ide/lib/mirror', () => {
};
const connectPass = () => waitForConnection().then(() => mockWebSocket.onopen());
const connectFail = () => waitForConnection().then(() => mockWebSocket.onerror());
- const sendResponse = msg => {
+ const sendResponse = (msg) => {
mockWebSocket.onmessage(msg);
};