Skip to content

Commit

Permalink
Fix base64 serializer tests (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva authored Apr 18, 2023
1 parent 2756a69 commit f48d4c2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/umi/src/errors/InvalidBaseStringError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { SdkError } from './SdkError';
export class InvalidBaseStringError extends SdkError {
readonly name: string = 'InvalidBaseStringError';

constructor(value: string, base: number) {
constructor(value: string, base: number, cause?: Error) {
const message = `Expected a string of base ${base}, got [${value}].`;
super(message);
super(message, cause);
}
}
2 changes: 1 addition & 1 deletion packages/umi/src/utils/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const base64: Serializer<string> = {
.map((c) => c.charCodeAt(0))
);
} catch (e) {
throw new InvalidBaseStringError(value, 64);
throw new InvalidBaseStringError(value, 64, e as Error);
}
},
deserialize(buffer, offset = 0) {
Expand Down
1 change: 0 additions & 1 deletion packages/umi/test/utils/bytes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ test('it can serialize base 64 strings', (t) => {
t.deepEqual(base64.deserialize(new Uint8Array([])), ['', 0]);

t.deepEqual(base64.serialize('AA'), new Uint8Array([0]));
t.deepEqual(base64.serialize('AA='), new Uint8Array([0]));
t.deepEqual(base64.serialize('AA=='), new Uint8Array([0]));
t.deepEqual(base64.deserialize(new Uint8Array([0])), ['AA==', 1]);

Expand Down

0 comments on commit f48d4c2

Please sign in to comment.