Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pug-linker] Add regression tests for #1261 #2687

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/pug/test/regression-1261/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
exports[`test #1261 - issue 1 - page with nested append 1`] = `
"
<script>console.log(\"page1\");</script>
<script>console.log(\"page1 in content\");</script>
<p>page 1</p>"
`;

exports[`test #1261 - issue 2 - append/prepend in include 1`] = `
"
<script>console.log(\"page1\");</script>
<script>console.log(\"page2\");</script>
<p>page 1</p>
<p>page 2</p>"
`;

exports[`test #1261 - issue 3 - append inside include inside append content 1`] = `
"
<script>console.log(\"page1\");</script>
<script>console.log(\"page2\");</script>
<p>page 1</p>
<p>page 2</p>"
`;
29 changes: 29 additions & 0 deletions packages/pug/test/regression-1261/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const pug = require('../../');

// Issue 1: block append in another block append duplicates the content of the inner block append,
// in different order furthermore.
test('#1261 - issue 1 - page with nested append', () => {
const output = pug.renderFile(
__dirname + '/page1-issue1.pug',
{pretty: true}
);
expect(output).toMatchSnapshot();
});

// Issue 2: append order is not the expected one: page 2 should be after page 1 in both script & content blocks.
test('#1261 - issue 2 - append/prepend in include', () => {
const output = pug.renderFile(
__dirname + '/page1-issue2.pug',
{pretty: true}
);
expect(output).toMatchSnapshot();
});

// Issue 3: block scripts is duplicated like in issue 1, but the order is the same in the two copies...
test('#1261 - issue 3 - append inside include inside append content', () => {
const output = pug.renderFile(
__dirname + '/page1-issue3.pug',
{pretty: true}
);
expect(output).toMatchSnapshot();
});
3 changes: 3 additions & 0 deletions packages/pug/test/regression-1261/layout.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
block scripts

block content
9 changes: 9 additions & 0 deletions packages/pug/test/regression-1261/page1-issue1.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends ./layout.pug

append scripts
script console.log("page1");

append content
p page 1
append scripts
script console.log("page1 in content");
9 changes: 9 additions & 0 deletions packages/pug/test/regression-1261/page1-issue2.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends ./layout.pug

append scripts
script console.log("page1");

append content
p page 1

include ./page2.pug
8 changes: 8 additions & 0 deletions packages/pug/test/regression-1261/page1-issue3.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends ./layout.pug

append scripts
script console.log("page1");

append content
p page 1
include ./page2.pug
5 changes: 5 additions & 0 deletions packages/pug/test/regression-1261/page2.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
append scripts
script console.log("page2");

append content
p page 2