Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
chore: make snap ID optional
Browse files Browse the repository at this point in the history
  • Loading branch information
danroc committed Aug 4, 2023
1 parent ef2831f commit d94cfdc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
38 changes: 32 additions & 6 deletions src/internal/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,49 @@ describe('InternalAccount', () => {
expect(() => assert(account, InternalAccountStruct)).not.toThrow();
});

it('should throw if snap ID is missing', () => {
it('should throw if metadata.keyring.type is not set', () => {
const account = {
id: '606a7759-b0fb-48e4-9874-bab62ff8e7eb',
address: '0x000',
options: {},
methods: [],
type: 'eip155:eoa',
metadata: {
snap: {},
keyring: {
type: 'Test Keyring',
},
keyring: {},
},
};

expect(() => assert(account, InternalAccountStruct)).toThrow(
'At path: metadata.snap.id -- Expected a string, but received: undefined',
'At path: metadata.keyring.type -- Expected a string, but received: undefined',
);
});

it('should throw if metadata.keyring is not set', () => {
const account = {
id: '606a7759-b0fb-48e4-9874-bab62ff8e7eb',
address: '0x000',
options: {},
methods: [],
type: 'eip155:eoa',
metadata: {},
};

expect(() => assert(account, InternalAccountStruct)).toThrow(
'At path: metadata.keyring -- Expected an object, but received: undefined',
);
});

it('should throw if metadata is not set', () => {
const account = {
id: '606a7759-b0fb-48e4-9874-bab62ff8e7eb',
address: '0x000',
options: {},
methods: [],
type: 'eip155:eoa',
};

expect(() => assert(account, InternalAccountStruct)).toThrow(
'At path: metadata -- Expected an object, but received: undefined',
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const InternalAccountStruct = object({
metadata: object({
snap: optional(
object({
id: string(),
id: optional(string()),
name: optional(string()),
enabled: optional(boolean()),
}),
Expand Down

0 comments on commit d94cfdc

Please sign in to comment.