heimdalljs
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,2 @@ | ||
var Heimdall = require('./lib/heimdall');; | ||
var Heimdall = require('./src/heimdall');; | ||
module.exports = Heimdall; |
'use strict'; | ||
var Heimdall = require('./lib/heimdall'); | ||
var Heimdall = require('./src/heimdall'); | ||
var semver = require('semver'); | ||
@@ -5,0 +5,0 @@ var version = require('./package.json').version; |
{ | ||
"name": "heimdalljs", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Structured instrumentation library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var chai = require('chai'), expect = chai.expect; | ||
var chaiAsPromised = require('chai-as-promised'); | ||
var chaiFiles = require('chai-files'), file = chaiFiles.file; | ||
var RSVP = require('RSVP'); | ||
var RSVP = require('rsvp'); | ||
var heimdall = require('../'); | ||
@@ -191,3 +191,9 @@ | ||
var json = heimdall.toJSON(); | ||
var nodeA = json.nodes.find(function (n) { return n.id.name === 'node-a'; }); | ||
var nodeA; | ||
for (var i=0; i<json.nodes.length; ++i) { | ||
if (json.nodes[i].id.name === 'node-a') { | ||
nodeA = json.nodes[i]; | ||
break; | ||
} | ||
} | ||
@@ -344,2 +350,60 @@ expect(nodeA).to.not.eql(undefined); | ||
describe('nodes', function() { | ||
function nodeNames() { | ||
var count = 0; | ||
var names = []; | ||
heimdall.visitPreOrder(function (node) { | ||
names.push(node.id.name); | ||
}); | ||
// ignore root | ||
return names.slice(1).join(' '); | ||
} | ||
describe('.remove', function() { | ||
describe('for the root node', function() { | ||
it('throws an error', function() { | ||
expect(function () { | ||
expect(heimdall.current.isRoot).to.equal(true); | ||
heimdall.current.remove(); | ||
}).to.throw('Cannot remove the root heimdalljs node.'); | ||
}); | ||
}); | ||
describe('for non-root nodes', function() { | ||
it('frees the node from its parent', function() { | ||
expect(nodeNames()).to.equal(''); | ||
var cookieA = heimdall.start('a'); | ||
var cookieAA = heimdall.start('aa'); | ||
expect(nodeNames()).to.equal('a aa'); | ||
cookieAA.stop(); | ||
expect(nodeNames()).to.equal('a aa'); | ||
expect(cookieAA.node.remove()).to.equal(cookieAA.node); | ||
expect(nodeNames()).to.equal('a'); | ||
}); | ||
}); | ||
// Really this is an error for any active node (ie path from current -> | ||
// root | ||
// | ||
// A case could be made it's an error for any node with an outstanding | ||
// cookie | ||
describe('for the current node', function() { | ||
it('throws an error', function() { | ||
var cookie = heimdall.start('node'); | ||
expect(function () { | ||
cookie.node.remove(); | ||
}).to.throw('Cannot remove an active heimdalljs node.'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('monitors', function() { | ||
@@ -346,0 +410,0 @@ function MonitorSchema() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24448
11
652