Sha256: 34dfab25d63a0cae422d149e3de935ea29bd68d8dc11261a4cc2a3a64b7b11df

Contents?: true

Size: 1.78 KB

Versions: 9

Compression:

Stored size: 1.78 KB

Contents

// ==========================================================================
// Project:   Spade - CommonJS Runtime
// Copyright: ©2011 Strobe Inc. All rights reserved.
// License:   Licened under MIT license (see __preamble__.js)
// ==========================================================================

var Ct = require('core-test/sync'),
    Spade = require('spade').Spade,
    Sandbox = require('spade').Sandbox;

Ct.module('spade: Sandbox Miscellaneous');

Ct.setup(function(t){
  t.sandbox = new Sandbox(new Spade(), 'Test Sandbox');
});

Ct.teardown(function(t){
  delete t.sandbox;
});

Ct.test('toString', function(t){
  t.equal(t.sandbox.toString(), '[Sandbox Test Sandbox]');
});

Ct.test("exists", function(t){
  t.sandbox.spade.register('test', { name: 'test' });
  t.sandbox.spade.register('test/main', '');

  t.ok(t.sandbox.exists('test'), "test should exist");
  t.ok(!t.sandbox.exists('missing'), "missing should not exist");
});

Ct.test("async", function(t){
  t.sandbox.spade.register('test', { name: 'test' });
  t.sandbox.spade.register('test/main', 'exports.hello = "hi";');

  t.deepEqual(t.sandbox.async('test'), {
    "data": "exports.hello = \"hi\";",
    "filename": "test/main",
    "format": "js"
  });
});

Ct.test("url", function(t){
  t.sandbox.spade.register('no-root', { name: 'no-root' });
  t.sandbox.spade.register('with-root', { name: 'with-root', root: 'root/url' });

  t.throws(function(){ t.sandbox.url('missing') }, "Can't get url for non-existent package missing/main");
  t.throws(function(){ t.sandbox.url('no-root') }, "Package for no-root/main does not support urls");
  t.equal(t.sandbox.url('with-root'), 'root/url/main');
});

Ct.test("destroy", function(t){
  t.equal(t.sandbox.isDestroyed, false);
  t.sandbox.destroy();
  t.equal(t.sandbox.isDestroyed, true);
});

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
spade-runtime-0.1.0.1 spec/javascript/sandbox/misc.js
spade-0.0.8.1 spec/javascript/sandbox/misc.js
spade-0.0.7 spec/javascript/sandbox/misc.js
spade-0.0.6 spec/javascript/sandbox/misc.js
spade-0.0.5 spec/javascript/sandbox/misc.js
spade-0.0.4 spec/javascript/sandbox/misc.js
spade-0.0.3 spec/javascript/sandbox/misc.js
spade-0.0.2 spec/javascript/sandbox/misc.js
spade-0.0.1 spec/javascript/sandbox/misc.js