Add tests for toBigInt usage (#3049)

* Add tests for toBigInt usage

* Update packages/types/src/codec/UInt.spec.ts
This commit is contained in:
Jaco Greeff
2021-01-13 13:00:10 +01:00
committed by GitHub
parent 527c0f5015
commit 429bf5456e
3 changed files with 15 additions and 1 deletions
+3 -1
View File
@@ -73,7 +73,9 @@ describe('Compact', (): void => {
});
it('has a valid toBigInt interface', (): void => {
expect(new (Compact.with('u128'))(registry, 12345678987654321n).toBigInt() === 12345678987654321n).toBe(true);
expect(
(new (Compact.with('u128'))(registry, 12345678987654321n).toBigInt() + 1n) === 12345678987654322n
).toBe(true);
});
});
});
+6
View File
@@ -59,6 +59,12 @@ describe('Date', (): void => {
new CodecDate(registry, 3).toHex(true)
).toEqual('0x0300000000000000');
});
it('encodes correctly to BigInt', (): void => {
expect(
new CodecDate(registry, 41).toBigInt() + 1n
).toEqual(42n);
});
});
describe('utils', (): void => {
+6
View File
@@ -45,6 +45,12 @@ describe('UInt', (): void => {
).toEqual(4567);
});
it('has a working toBigInt', (): void => {
expect(
new UInt(registry, 4567).toBigInt() + BigInt(1)
).toEqual(BigInt(4568));
});
it('converts to Little Endian from the provided value', (): void => {
expect(
new UInt(registry, 1234567).toU8a()