From 65e445ede56d22960380956091da52452c4e9586 Mon Sep 17 00:00:00 2001 From: Secbone Date: Sun, 29 Jan 2017 23:20:15 +0800 Subject: [PATCH] Add regression tests for #2436 --- .../__snapshots__/index.test.js.snap | 15 +++++++++++++++ packages/pug/test/regression-2436/index.test.js | 17 +++++++++++++++++ packages/pug/test/regression-2436/issue1.pug | 7 +++++++ packages/pug/test/regression-2436/issue2.pug | 7 +++++++ packages/pug/test/regression-2436/layout.pug | 6 ++++++ packages/pug/test/regression-2436/other1.pug | 4 ++++ packages/pug/test/regression-2436/other2.pug | 4 ++++ .../pug/test/regression-2436/other_layout.pug | 4 ++++ 8 files changed, 64 insertions(+) create mode 100644 packages/pug/test/regression-2436/__snapshots__/index.test.js.snap create mode 100644 packages/pug/test/regression-2436/index.test.js create mode 100644 packages/pug/test/regression-2436/issue1.pug create mode 100644 packages/pug/test/regression-2436/issue2.pug create mode 100644 packages/pug/test/regression-2436/layout.pug create mode 100644 packages/pug/test/regression-2436/other1.pug create mode 100644 packages/pug/test/regression-2436/other2.pug create mode 100644 packages/pug/test/regression-2436/other_layout.pug diff --git a/packages/pug/test/regression-2436/__snapshots__/index.test.js.snap b/packages/pug/test/regression-2436/__snapshots__/index.test.js.snap new file mode 100644 index 000000000..afb4067e7 --- /dev/null +++ b/packages/pug/test/regression-2436/__snapshots__/index.test.js.snap @@ -0,0 +1,15 @@ +exports[`test #2436 - block with a same name extends from different layout in nesting 1`] = ` +" +

layout

+

Other A

+

other layout

+

Other A

" +`; + +exports[`test #2436 - block with a same name extends from the same layout in nesting 1`] = ` +" +

layout

+

Other A

+

layout

+

Other A

" +`; diff --git a/packages/pug/test/regression-2436/index.test.js b/packages/pug/test/regression-2436/index.test.js new file mode 100644 index 000000000..47a1ae44b --- /dev/null +++ b/packages/pug/test/regression-2436/index.test.js @@ -0,0 +1,17 @@ +const pug = require('../../'); + +test('#2436 - block with a same name extends from the same layout in nesting', () => { + const output = pug.renderFile( + __dirname + '/issue1.pug', + {pretty: true} + ); + expect(output).toMatchSnapshot(); +}); + +test('#2436 - block with a same name extends from different layout in nesting', () => { + const output = pug.renderFile( + __dirname + '/issue2.pug', + {pretty: true} + ); + expect(output).toMatchSnapshot(); +}); diff --git a/packages/pug/test/regression-2436/issue1.pug b/packages/pug/test/regression-2436/issue1.pug new file mode 100644 index 000000000..f521c6ea2 --- /dev/null +++ b/packages/pug/test/regression-2436/issue1.pug @@ -0,0 +1,7 @@ +extends layout.pug + +block a + p Main A + +block b + include other1.pug diff --git a/packages/pug/test/regression-2436/issue2.pug b/packages/pug/test/regression-2436/issue2.pug new file mode 100644 index 000000000..7acba598a --- /dev/null +++ b/packages/pug/test/regression-2436/issue2.pug @@ -0,0 +1,7 @@ +extends layout.pug + +block a + p Main A + +block b + include other2.pug diff --git a/packages/pug/test/regression-2436/layout.pug b/packages/pug/test/regression-2436/layout.pug new file mode 100644 index 000000000..71ad7eb93 --- /dev/null +++ b/packages/pug/test/regression-2436/layout.pug @@ -0,0 +1,6 @@ +h1 layout + +block a + p block in layout + +block b diff --git a/packages/pug/test/regression-2436/other1.pug b/packages/pug/test/regression-2436/other1.pug new file mode 100644 index 000000000..206cb4fc9 --- /dev/null +++ b/packages/pug/test/regression-2436/other1.pug @@ -0,0 +1,4 @@ +extends layout.pug + +block a + p Other A diff --git a/packages/pug/test/regression-2436/other2.pug b/packages/pug/test/regression-2436/other2.pug new file mode 100644 index 000000000..6329aebb0 --- /dev/null +++ b/packages/pug/test/regression-2436/other2.pug @@ -0,0 +1,4 @@ +extends other_layout.pug + +block a + p Other A diff --git a/packages/pug/test/regression-2436/other_layout.pug b/packages/pug/test/regression-2436/other_layout.pug new file mode 100644 index 000000000..edda16157 --- /dev/null +++ b/packages/pug/test/regression-2436/other_layout.pug @@ -0,0 +1,4 @@ +h1 other layout + +block a + p block in other layout