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-08-26 12:10:16 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-26 12:10:16 +0300
commit2c49951e8c1f4fb95d15cac3dd0677d6882d2add (patch)
treeacca123398daa394dd9810ac47ac07319c53e9a9 /spec/frontend/static_site_editor
parentfb553bbc1899eddaddb07cd9685cdabffbed9962 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/static_site_editor')
-rw-r--r--spec/frontend/static_site_editor/services/parse_source_file_spec.js38
1 files changed, 37 insertions, 1 deletions
diff --git a/spec/frontend/static_site_editor/services/parse_source_file_spec.js b/spec/frontend/static_site_editor/services/parse_source_file_spec.js
index 4588548e614..19d1a21991f 100644
--- a/spec/frontend/static_site_editor/services/parse_source_file_spec.js
+++ b/spec/frontend/static_site_editor/services/parse_source_file_spec.js
@@ -1,4 +1,8 @@
-import { sourceContent as content, sourceContentBody as body } from '../mock_data';
+import {
+ sourceContent as content,
+ sourceContentHeader as frontMatter,
+ sourceContentBody as body,
+} from '../mock_data';
import parseSourceFile from '~/static_site_editor/services/parse_source_file';
@@ -9,6 +13,16 @@ describe('parseSourceFile', () => {
const newContent = `${content} ${edit}`;
const newContentComplex = `${contentComplex} ${edit}`;
+ describe('unmodified front matter', () => {
+ it.each`
+ parsedSource
+ ${parseSourceFile(content)}
+ ${parseSourceFile(contentComplex)}
+ `('returns the correct front matter when queried', ({ parsedSource }) => {
+ expect(parsedSource.frontMatter()).toBe(frontMatter);
+ });
+ });
+
describe('unmodified content', () => {
it.each`
parsedSource
@@ -34,6 +48,28 @@ describe('parseSourceFile', () => {
);
});
+ describe('modified front matter', () => {
+ const newFrontMatter = '---\nnewKey: newVal\n---';
+ const contentWithNewFrontMatter = content.replace(frontMatter, newFrontMatter);
+ const contentComplexWithNewFrontMatter = contentComplex.replace(frontMatter, newFrontMatter);
+
+ it.each`
+ parsedSource | targetContent
+ ${parseSourceFile(content)} | ${contentWithNewFrontMatter}
+ ${parseSourceFile(contentComplex)} | ${contentComplexWithNewFrontMatter}
+ `(
+ 'returns the correct front matter and modified content',
+ ({ parsedSource, targetContent }) => {
+ expect(parsedSource.frontMatter()).toBe(frontMatter);
+
+ parsedSource.setFrontMatter(newFrontMatter);
+
+ expect(parsedSource.frontMatter()).toBe(newFrontMatter);
+ expect(parsedSource.content()).toBe(targetContent);
+ },
+ );
+ });
+
describe('modified content', () => {
const newBody = `${body} ${edit}`;
const newComplexBody = `${complexBody} ${edit}`;