Skip to content

Commit

Permalink
better test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmannjan committed Jan 31, 2022
1 parent db31df1 commit 8889c9c
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions src/lib/CLValue/Tuple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,44 @@ describe('CLTuple', () => {

it('fromJSON() / toJSON()', () => {
const arr = new CLByteArray(Uint8Array.from([1, 2, 3]));
const uint8 = new Uint8Array();
uint8.fill(1, 0, 32);
const arr2 = new CLByteArray(uint8);
const arr2 = new CLByteArray(
Uint8Array.from([
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34
])
);

const myTup1 = new CLTuple1([arr]);
const myTup2 = new CLTuple2([arr, arr2]);
Expand All @@ -133,12 +168,12 @@ describe('CLTuple', () => {

const myTup2JSON = CLValueParsers.toJSON(myTup2).unwrap();
const expectedMyTup2JSON = JSON.parse(
`{"bytes":"010203","cl_type":{"Tuple2":[{"ByteArray":3},{"ByteArray":0}]}}`
`{"bytes":"0102030102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122","cl_type":{"Tuple2":[{"ByteArray":3},{"ByteArray":34}]}}`
);

const myTup3JSON = CLValueParsers.toJSON(myTup3).unwrap();
const expectedMyTup3JSON = JSON.parse(
`{"bytes":"01020303000000414243","cl_type":{"Tuple3":[{"ByteArray":3},{"ByteArray":0},"String"]}}`
`{"bytes":"0102030102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212203000000414243","cl_type":{"Tuple3":[{"ByteArray":3},{"ByteArray":34},"String"]}}`
);

expect(myTup1JSON).to.be.deep.eq(expectedMyTup1JSON);
Expand Down

0 comments on commit 8889c9c

Please sign in to comment.