Comparing version 0.0.9 to 0.0.10
@@ -43,3 +43,3 @@ "use strict"; | ||
value: function set(aSwitch, value) { | ||
if (typeof aSwtch === "string") { | ||
if (isString(aSwitch)) { | ||
aSwitch = this.constructor._switchOn.fromName(aSwitch); | ||
@@ -46,0 +46,0 @@ } |
{ | ||
"name": "js-xdr", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Read/write XDR encoded data structures (RFC 4506)", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -13,6 +13,6 @@ import { each, isUndefined, isString } from "lodash"; | ||
set(aSwitch, value) { | ||
if (typeof aSwtch === "string") { | ||
if (isString(aSwitch)) { | ||
aSwitch = this.constructor._switchOn.fromName(aSwitch); | ||
} | ||
this._switch = aSwitch; | ||
@@ -19,0 +19,0 @@ this._arm = this.constructor.armForSwitch(this._switch); |
@@ -48,8 +48,30 @@ import { Cursor } from "../../src/cursor"; | ||
describe('new Union', function() { | ||
describe('Union: constructor', function() { | ||
it('works for XDR.Int discrimnated unions', function() { | ||
expect(() => new Ext(0)).to.not.throw(); | ||
}); | ||
it('works for Enum discrimnated unions', function() { | ||
expect(() => new Result("ok")).to.not.throw(); | ||
expect(() => new Result(ResultType.ok())).to.not.throw(); | ||
}); | ||
}); | ||
describe('Union: set', function() { | ||
it('works for XDR.Int discrimnated unions', function() { | ||
let u = new Ext(0); | ||
u.set(0); | ||
}); | ||
it('works for Enum discrimnated unions', function() { | ||
let u = Result.ok(); | ||
expect(() => u.set("ok")).to.not.throw(); | ||
expect(() => u.set("notok")).to.throw(/not a member/); | ||
expect(() => u.set(ResultType.ok())).to.not.throw(); | ||
}); | ||
}); | ||
describe('Union.read', function() { | ||
@@ -56,0 +78,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
960613
22617