Add tests for toBigInt usage (#3049)
* Add tests for toBigInt usage * Update packages/types/src/codec/UInt.spec.ts
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user