Skip to content

Commit

Permalink
Parser.test.js: Update tests to support context-aware includes
Browse files Browse the repository at this point in the history
As parser now supports context-aware includes, we need to update
our unit tests for parser to check that our data-included-from
tags are correct.

Let's update our unit tests in parser.test.js.
  • Loading branch information
sijie123 committed Apr 15, 2019
1 parent 763a0fb commit e450b1e
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions test/unit/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ test('includeFile replaces <include> with <div>', async () => {

const expected = [
'# Index',
`<div cwf="${indexPath}" include-path="${includePath}">`,
`<div cwf="${indexPath}" include-path="${includePath}">`
+ `<div data-included-from="${includePath}" cwf="${includePath}">`,
'',
'# Include',
'</div>',
'</div></div>',
'',
].join('\n');

Expand Down Expand Up @@ -85,10 +86,11 @@ test('includeFile replaces <include src="exist.md" optional> with <div>', async

const expected = [
'# Index',
`<div cwf="${indexPath}" include-path="${existPath}">`,
`<div cwf="${indexPath}" include-path="${existPath}">`
+ `<div data-included-from="${existPath}" cwf="${existPath}">`,
'',
'# Exist',
'</div>',
'</div></div>',
'',
].join('\n');

Expand Down Expand Up @@ -161,10 +163,11 @@ test('includeFile replaces <include src="include.md#exists"> with <div>', async

const expected = [
'# Index',
`<div cwf="${indexPath}" include-path="${includePath}">`,
`<div cwf="${indexPath}" include-path="${includePath}">`
+ `<div data-included-from="${includePath}" cwf="${includePath}">`,
'',
'existing segment',
'</div>',
'</div></div>',
'',
].join('\n');

Expand Down Expand Up @@ -205,7 +208,8 @@ test('includeFile replaces <include src="include.md#exists" inline> with inline

const expected = [
'# Index',
`<span cwf="${indexPath}" include-path="${includePath}">existing segment</span>`,
`<span cwf="${indexPath}" include-path="${includePath}">`
+ `<div data-included-from="${includePath}" cwf="${includePath}">existing segment</div></span>`,
'',
].join('\n');

Expand Down Expand Up @@ -245,10 +249,11 @@ test('includeFile replaces <include src="include.md#exists" trim> with trimmed c

const expected = [
'# Index',
`<div cwf="${indexPath}" include-path="${includePath}">`,
`<div cwf="${indexPath}" include-path="${includePath}">`
+ `<div data-included-from="${includePath}" cwf="${includePath}">`,
'',
'existing segment',
'</div>',
'</div></div>',
'',
].join('\n');

Expand Down Expand Up @@ -332,10 +337,11 @@ test('includeFile replaces <include src="include.md#exists" optional> with <div>

const expected = [
'# Index',
`<div cwf="${indexPath}" include-path="${includePath}">`,
`<div cwf="${indexPath}" include-path="${includePath}">`
+ `<div data-included-from="${includePath}" cwf="${includePath}">`,
'',
'existing segment',
'</div>',
'</div></div>',
'',
].join('\n');

Expand Down Expand Up @@ -372,10 +378,11 @@ test('includeFile replaces <include src="include.md#doesNotExist" optional> with

const expected = [
'# Index',
`<div cwf="${indexPath}" include-path="${includePath}">`,
`<div cwf="${indexPath}" include-path="${includePath}">`
+ `<div data-included-from="${includePath}" cwf="${includePath}">`,
'',
'',
'</div>',
'</div></div>',
'',
].join('\n');

Expand Down

0 comments on commit e450b1e

Please sign in to comment.