Skip to content
This repository
Browse code

fill in tests for fromFile

  • Loading branch information...
commit b568d4159ea6c52c4f4a94133f0084dfe308b858 1 parent 45df0cc
Paul Armstrong authored

Showing 1 changed file with 19 additions and 3 deletions. Show diff stats Hide diff stats

  1. +19 3 tests/index.test.js
22 tests/index.test.js
@@ -6,7 +6,19 @@ exports.fromFile = testCase({
6 6 callback();
7 7 },
8 8
9   - 'file not exist': function (test) {
  9 + basic: function (test) {
  10 + swig.init({
  11 + root: __dirname + '/templates',
  12 + allowErrors: true
  13 + });
  14 +
  15 + var tpl = swig.fromFile('included_2.html');
  16 + test.strictEqual('2', tpl.render({ array: [1, 1] }), 'from file is a-ok');
  17 +
  18 + test.done();
  19 + },
  20 +
  21 + 'allowErrors = false': function (test) {
10 22 swig.init({
11 23 root: __dirname + '/templates',
12 24 allowErrors: false
@@ -14,11 +26,15 @@ exports.fromFile = testCase({
14 26 var tpl = swig.fromFile('foobar.html');
15 27 test.ok((/<pre>Error\: EBADF, Bad file descriptor/).test(tpl.render()), 'pushes a render function with the error');
16 28 tpl = swig.fromFile('includes_notfound.html');
17   - test.ok((/<pre>Error\: EBADF, Bad file descriptor/).test(tpl.render()), 'pushes a render function with the error');
  29 + test.ok((/<pre>Error\: EBADF, Bad file descriptor/).test(tpl.render()), 'renders the error when includes a file that is not found');
  30 +
  31 + test.done();
  32 + },
18 33
  34 + 'allowErrors = true': function (test) {
19 35 swig.init({ allowErrors: true });
20 36 test.throws(function () {
21   - tpl = swig.fromFile('barfoo.html');
  37 + swig.fromFile('barfoo.html');
22 38 }, 'throws when allowErrors is true');
23 39
24 40 test.done();

0 comments on commit b568d41

Please sign in to comment.
Something went wrong with that request. Please try again.