From 097fc5c90c02004dd11d45a9518dfbe0a32df3a8 Mon Sep 17 00:00:00 2001 From: smcatala Date: Tue, 29 Nov 2016 09:00:06 +0100 Subject: [PATCH] add test for strict-mode compliance Signed-off-by: S. M. Catala --- test/clientside/run.js | 1 + test/clientside/use-strict.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/clientside/use-strict.js diff --git a/test/clientside/run.js b/test/clientside/run.js index 99a117b..bf1a1bf 100644 --- a/test/clientside/run.js +++ b/test/clientside/run.js @@ -50,6 +50,7 @@ var clientTests = [ , 'noCallThru' , 'argument-validation' , 'falsy' + , 'use-strict' ]; compileAll(clientTests, function (err, results) { diff --git a/test/clientside/use-strict.js b/test/clientside/use-strict.js new file mode 100644 index 0000000..b9f2cfe --- /dev/null +++ b/test/clientside/use-strict.js @@ -0,0 +1,18 @@ +// comments are ok before 'use strict' +'use strict' + +var proxyquire = require('proxyquireify')(require) +var barber = { + bar: function () { return 'barber' } +} + +function proxy () { + // missing var declaration throws in strict-mode, otherwise not + foober = proxyquire('../fixtures/foo', { './bar': barber }) + return foober +} + +test('\nstrict mode compliant', function (t) { + t.throws(proxy, new ReferenceError('foober is not defined'), 'strict mode is active') + t.end() +})