diff --git a/test/fixtures/tpl-render-result/import-render-nigeru.html b/test/fixtures/tpl-render-result/import-render-nigeru.html
new file mode 100644
index 0000000..559fd11
--- /dev/null
+++ b/test/fixtures/tpl-render-result/import-render-nigeru.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+ 逃げる
+
+
+
+
+ 逃げる
+ 逃げちゃだめだ。逃げちゃだめだ。逃げちゃだめだ。
+
+
+
\ No newline at end of file
diff --git a/test/fixtures/tpl-test/import-render-case/layout/template.njk b/test/fixtures/tpl-test/import-render-case/layout/template.njk
new file mode 100644
index 0000000..9f769d6
--- /dev/null
+++ b/test/fixtures/tpl-test/import-render-case/layout/template.njk
@@ -0,0 +1,21 @@
+
+
+
+
+
+ {{ title }}
+
+
+
+
+ 逃げる
+ {{ body }}
+
+
+
\ No newline at end of file
diff --git a/test/fixtures/tpl-test/import-render-case/source/style.css b/test/fixtures/tpl-test/import-render-case/source/style.css
new file mode 100644
index 0000000..2435aff
--- /dev/null
+++ b/test/fixtures/tpl-test/import-render-case/source/style.css
@@ -0,0 +1,3 @@
+#nigeru {
+ background-color: green;
+}
\ No newline at end of file
diff --git a/test/nunjucks.test.ts b/test/nunjucks.test.ts
index 3cf9c8e..21c7e41 100644
--- a/test/nunjucks.test.ts
+++ b/test/nunjucks.test.ts
@@ -4,11 +4,13 @@ import * as path from 'path';
import * as CONST from './constants';
const NjkLoaders = require('../tools/njk-loader');
+function getNJKEnv(tplDir: string | string[]) {
+ return new nunjucks.Environment(
+ new NjkLoaders.TemplateLoader(tplDir));
+}
+
test('TemplateLoader Basic Usage', done => {
- const njk_env = new nunjucks.Environment(
- new NjkLoaders.TemplateLoader(path.join(CONST.TEST_TEMPLATE_DIR, './basic-render-case')),
- // new nunjucks.FileSystemLoader(path.join(CONST.TEST_TEMPLATE_DIR, './basic-render-case')),
- );
+ const njk_env = getNJKEnv(path.join(CONST.TEST_TEMPLATE_DIR, './basic-render-case'));
njk_env.render('layout/template.njk', {
title: '逃げる',
body: '逃げちゃだめだ。逃げちゃだめだ。逃げちゃだめだ。',
@@ -25,3 +27,22 @@ test('TemplateLoader Basic Usage', done => {
return done();
});
});
+
+test('Basic External Source Import Testing', done => {
+ const njk_env = getNJKEnv([
+ path.join(CONST.TEST_TEMPLATE_DIR, './import-render-case'),
+ path.join(CONST.TEST_TEMPLATE_DIR, './import-render-case/source'),
+ ]);
+ njk_env.render('layout/template.njk', {
+ title: '逃げる',
+ body: '逃げちゃだめだ。逃げちゃだめだ。逃げちゃだめだ。',
+ }, (err, result) => {
+ expect(err).toBeNull();
+ expect(result).toEqual(
+ fs.readFileSync(
+ path.resolve(CONST.RENDER_CASE_DIR, './import-render-nigeru.html')
+ , 'utf8'));
+
+ return done();
+ });
+});