Sha256: 1dfec06767c2a293c48e10db56b35cabc2732d1bef4b882fc9725562bc9e4c09

Contents?: true

Size: 1.81 KB

Versions: 10

Compression:

Stored size: 1.81 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: relative require');

Ct.setup(function(t) {
  t.spade = new Spade(); 
  
  ['foo', 'bar'].forEach(function(id) {
    t.spade.register(id, { "name": id });
  });
  
  // register some dummy modules.  These will just set an 'id' prop on exports
  ['foo/bar', 'bar/main', 'foo/bar/baz'].forEach(function(id) {
    t.spade.register(id, function(r, e) { e.id = id; });
  });
  
});

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

Ct.test('require absolute', function(t) {
  var spade = t.spade;

  spade.register('blah/main', function(require, e) {
    e.found = require('foo/bar').id;
  });

  t.equal(spade.require('blah').found, 'foo/bar');
});

Ct.test('require relative top level', function(t) {
  var spade = t.spade;
  spade.register('blah/main', function(require, e) { 
    e.found = require('../bar').id; 
  });
  
  t.equal(spade.require('blah').found, 'bar/main');
});

Ct.test('require relative nested', function(t) {
  var spade = t.spade;
  spade.register('foo/blah', function(require, e) { 
    e.found = require('./bar').id; 
  });
  
  t.equal(spade.require('foo/blah').found, 'foo/bar');
});

Ct.test('require relative  up nested', function(t) {
  var spade = t.spade;
  spade.register('bar/blah', function(require, e) { 
    e.found = require('../foo/bar/baz').id; 
  });
  
  t.equal(spade.require('bar/blah').found, 'foo/bar/baz');
});


Ct.run();

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
spade-0.1.1.1 lib/spade/package/spec/javascript/relative-require-test.js
spade-runtime-0.1.0.1 spec/javascript/relative-require-test.js
spade-0.0.8.1 spec/javascript/relative-require-test.js
spade-0.0.7 spec/javascript/relative-require-test.js
spade-0.0.6 spec/javascript/relative-require-test.js
spade-0.0.5 spec/javascript/relative-require-test.js
spade-0.0.4 spec/javascript/relative-require-test.js
spade-0.0.3 spec/javascript/relative-require-test.js
spade-0.0.2 spec/javascript/relative-require-test.js
spade-0.0.1 spec/javascript/relative-require-test.js