Sha256: baab113d012be46c66444fe77150f85c61fe772a184db2f2593e9d57ae1d4b78
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
// ========================================================================== // Project: Spade - CommonJS Runtime // Copyright: ©2010 Strobe Inc. All rights reserved. // License: Licened under MIT license (see __preamble__.js) // ========================================================================== var Ct = require('core-test/sync'), Spade = require('spade').Spade; // .......................................................... // BASIC REQUIRE // Ct.module('spade: basic require'); Ct.setup(function(t) { t.spade = new Spade(); }); Ct.teardown(function(t) { delete t.spade; }); Ct.test('register then require a module', function(t) { var spade = t.spade; spade.register('foo/bar', function(require, exports) { exports.foo = 'bar'; }); var exp = spade.require('foo/bar'); t.equal(exp.foo, 'bar', 'exports.foo == bar - means require succeeded'); }); Ct.test('register a string factory then require', function(t) { var spade = t.spade; spade.register('foo/bar', "exports.foo = 'bar';"); var exp = spade.require('foo/bar'); t.equal(exp.foo, 'bar', 'exports.foo == bar - means require succeeded'); }); Ct.test('require a non-existant module will throw an exception', function(t) { var spade = t.spade; t.throws(function() { spade.require('imaginary/foo'); }, 'Module imaginary/foo not found'); }); Ct.test('require a module that was just registered symbolically. This is for compatibility with non-module items', function(t) { var spade = t.spade; spade.register('not/a-module'); t.ok(spade.require('not/a-module')); }); Ct.test('require system installed packages');
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spade-0.0.6 | spec/javascript/require-test.js |
spade-0.0.5 | spec/javascript/require-test.js |
spade-0.0.4 | spec/javascript/require-test.js |