-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): Add tests for accounts, bookmarks, etc
add more tests
- Loading branch information
Showing
26 changed files
with
331 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
src/mastodon/v1/repositories/__tests__/email-repository.spec.ts
This file was deleted.
Oops, something went wrong.
68 changes: 0 additions & 68 deletions
68
src/mastodon/v1/repositories/__tests__/status-repository.spec.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-interface */ | ||
/* eslint-disable @typescript-eslint/no-namespace */ | ||
export interface CustomMatchers<R = unknown> { | ||
toContainId(id: string): R; | ||
} | ||
|
||
declare global { | ||
namespace jest { | ||
interface Expect extends CustomMatchers {} | ||
interface Matchers<R> extends CustomMatchers<R> {} | ||
interface InverseAsymmetricMatchers extends CustomMatchers {} | ||
} | ||
} | ||
|
||
expect.extend({ | ||
toContainId<T extends { id: string }>(received?: T, expected?: string) { | ||
if (!Array.isArray(received)) { | ||
return { pass: false, message: () => 'Expected an array' }; | ||
} | ||
|
||
if (received.length === 0) { | ||
return { | ||
pass: false, | ||
message: () => 'Expected an array with at least one element', | ||
}; | ||
} | ||
|
||
const pass = received.some((entity) => entity.id === expected); | ||
|
||
return { | ||
pass, | ||
message: () => { | ||
return `List does not contain ${expected}`; | ||
}, | ||
}; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
it('lists directory', () => { | ||
return clients.use(async (client) => { | ||
const directory = await client.v1.directory.list(); | ||
expect(directory).toEqual(expect.any(Array)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
it('block a domain', () => { | ||
return clients.use(async (client) => { | ||
const domain = 'example.com'; | ||
|
||
await client.v1.domainBlocks.block(domain); | ||
let domainBlocks = await client.v1.domainBlocks.list(); | ||
expect(domainBlocks).toEqual(expect.arrayContaining([domain])); | ||
|
||
await client.v1.domainBlocks.unblock(domain); | ||
domainBlocks = await client.v1.domainBlocks.list(); | ||
expect(domainBlocks).not.toEqual(expect.arrayContaining([domain])); | ||
}); | ||
}); |
Oops, something went wrong.