@chix/flow
Version:
54 lines • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var identity_1 = require("../identity");
var TestBase = (function () {
function TestBase() {
}
return TestBase;
}());
var Identity = identity_1.$Identity(TestBase);
describe('Identity', function () {
it('Requires node parameter', function () {
chai_1.expect(function () { return new Identity(); }).to.throw(Error, /node parameter is required/);
});
it('Requires node id', function () {
chai_1.expect(function () { return new Identity({ node: {} }); }).to.throw(Error, /id is required/);
});
it('Requires node ns', function () {
chai_1.expect(function () { return new Identity({ node: { id: 'hw' } }); }).to.throw(Error, /ns is required/);
});
it('Requires node name', function () {
chai_1.expect(function () { return new Identity({ node: { id: 'hw', ns: 'hello' } }); }).to.throw(Error, /name is required/);
});
it('Requires node type', function () {
chai_1.expect(function () { return new Identity({ node: { id: 'hw', ns: 'hello', name: 'world' } }); }).to.throw(Error, /type is required/);
});
it('Builds correct identity', function () {
var identity = new Identity({
node: {
id: 'hw',
ns: 'hello',
name: 'world',
type: 'node',
},
});
chai_1.expect(identity.ns).to.equal('hello');
chai_1.expect(identity.name).to.equal('world');
chai_1.expect(identity.id).to.equal('hw');
chai_1.expect(identity.identifier).to.equal('hello:world');
});
it('Can override identifier', function () {
var identity = new Identity({
node: {
id: 'hw',
ns: 'hello',
name: 'world',
type: 'node',
},
});
identity.identifier = 'custom-identifier';
chai_1.expect(identity.identifier).to.equal('custom-identifier');
});
});
//# sourceMappingURL=identity.spec.js.map