-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): unsubscribe from topic
WIP, to be completed with API overhaul
- Loading branch information
1 parent
8c07fdf
commit fe5e61b
Showing
5 changed files
with
154 additions
and
42 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
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 |
---|---|---|
|
@@ -20,9 +20,14 @@ const mockedHandlers = { | |
orange: ['[email protected]', '[email protected]'], | ||
tangerine: [] | ||
}), | ||
removeTopic: jest.fn().mockResolvedValue({ | ||
banana: ['[email protected]'], | ||
tangerine: [] | ||
}), | ||
forceSubscription: jest | ||
.fn() | ||
.mockResolvedValue(['[email protected]', '[email protected]']) | ||
.mockResolvedValue(['[email protected]', '[email protected]']), | ||
cancelSubscription: jest.fn().mockResolvedValue(['[email protected]']) | ||
} | ||
|
||
describe('createRestifyServer()', () => { | ||
|
@@ -107,6 +112,21 @@ describe('createRestifyServer()', () => { | |
}) | ||
}) | ||
|
||
describe('[DELETE] /api/v1/topics', () => { | ||
it('[200] routes to removeTopic()', done => { | ||
// @ts-ignore | ||
client.del('/api/v1/topics', (_, __, res, data) => { | ||
expect(res.statusCode).toEqual(200) | ||
expect(data).toEqual({ | ||
banana: ['[email protected]'], | ||
tangerine: [] | ||
}) | ||
expect(mockedHandlers.removeTopic).toHaveBeenCalledWith('') | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('[PUT] /api/v1/topics/{topic}', () => { | ||
it("[400] requires 'user'", done => { | ||
client.put( | ||
|
@@ -255,7 +275,11 @@ describe('createRestifyServer()', () => { | |
it('[202] routes to broadcast() (considering topic creation)', done => { | ||
client.post( | ||
'/api/v1/broadcast', | ||
{ topic: 'orange', message: 'orange event', createTopicIfNotExists: true }, | ||
{ | ||
topic: 'orange', | ||
message: 'orange event', | ||
createTopicIfNotExists: true | ||
}, | ||
// @ts-ignore | ||
(_, __, res, data) => { | ||
expect(mockedHandlers.broadcast).toHaveBeenCalledWith( | ||
|
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