fix: rehydrate serialized BigNumber dishes
This commit is contained in:
parent
bd4c59cf34
commit
25fb514990
@ -292,7 +292,7 @@ class Dish {
|
|||||||
and reinitialise it as a BigNumber object.
|
and reinitialise it as a BigNumber object.
|
||||||
*/
|
*/
|
||||||
if (Object.keys(this.value).sort().equals(["c", "e", "s"])) {
|
if (Object.keys(this.value).sort().equals(["c", "e", "s"])) {
|
||||||
const temp = new BigNumber();
|
const temp = new BigNumber(0);
|
||||||
temp.c = this.value.c;
|
temp.c = this.value.c;
|
||||||
temp.e = this.value.e;
|
temp.e = this.value.e;
|
||||||
temp.s = this.value.s;
|
temp.s = this.value.s;
|
||||||
|
|||||||
@ -9,4 +9,14 @@ TestRegister.addApiTests([
|
|||||||
assert(dish.presentAs);
|
assert(dish.presentAs);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
it("Dish - isValid: rehydrates serialized BigNumber values", () => {
|
||||||
|
const dish = new Dish({ c: [1], e: 0, s: 1 }, Dish.BIG_NUMBER);
|
||||||
|
assert.strictEqual(dish.value.toString(), "1");
|
||||||
|
}),
|
||||||
|
|
||||||
|
it("Dish - isValid: rehydrates serialized NaN BigNumber values", () => {
|
||||||
|
const dish = new Dish({ c: null, e: null, s: null }, Dish.BIG_NUMBER);
|
||||||
|
assert.strictEqual(dish.value.toString(), "NaN");
|
||||||
|
}),
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user