This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (mostly pending) tests for messaging helper
- Loading branch information
Showing
3 changed files
with
67 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { describe, it, beforeEach } from 'mocha' | ||
import { expect } from 'chai' | ||
import { stubObject, StubbedInstance } from 'ts-sinon' | ||
import { Messaging as MessagingAPI } from '../../api-clients' | ||
import { kv } from './shared' | ||
import MessagingHelper from './messaging' | ||
import { Channel } from '../../messaging' | ||
|
||
describe(__filename, () => { | ||
describe('supporting functions', () => { | ||
describe('resolving channel', () => { | ||
let h: StubbedInstance<MessagingHelper> | ||
|
||
beforeEach(() => { | ||
h = stubObject<MessagingHelper>( | ||
new MessagingHelper({ MessagingAPI: new MessagingAPI({}) }), | ||
[ | ||
'findChannelByID', | ||
], | ||
) | ||
}) | ||
|
||
it('should return first valid channel', async () => { | ||
const c = new Channel({ channelID: '333' }) | ||
expect(await h.resolveChannel(undefined, null, false, 0, '', c)).to.deep.equal(c) | ||
expect(h.findChannelByID.notCalled, 'findChannelByID call not expected').true | ||
}) | ||
|
||
it('should resolve id', async () => { | ||
const c = new Channel({ channelID: '444' }) | ||
h.findChannelByID.resolves(c) | ||
expect(await h.resolveChannel(c.channelID)).to.deep.equal(c) | ||
expect(h.findChannelByID.calledOnceWith(c.channelID), 'findChannelByID call expected').true | ||
}) | ||
}) | ||
}) | ||
|
||
describe.skip('helpers', () => { | ||
it('should have tests for sendMessage') | ||
it('should have tests for findChannels') | ||
it('should have tests for findChanneldById') | ||
it('should have tests for directMessages') | ||
it('should have tests for saveChannel') | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
type PartialMessage = { [_: string]: unknown } | ||
|
||
export class Message { | ||
// @todo port message class here | ||
[_: string]: unknown | ||
|
||
constructor (m?: PartialMessage) { | ||
this.apply(m) | ||
} | ||
|
||
apply (m?: PartialMessage): void { | ||
Object.assign(this, m) | ||
} | ||
} |