Skip to content

Commit

Permalink
feat(test-utils): receiveGroupRequest change
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 27, 2020
1 parent 74ac6e0 commit 16fd63e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions packages/plugin-common/tests/handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ describe('type: undefined', () => {
})

test('group add', async () => {
app.receiveGroupRequest(321, 'add')
app.receiveGroupRequest('add', 321)
await sleep(0)
app.shouldHaveNoRequests()
})

test('group invite', async () => {
app.receiveGroupRequest(321, 'invite')
app.receiveGroupRequest('invite', 321)
await sleep(0)
app.shouldHaveNoRequests()
})
Expand All @@ -49,13 +49,13 @@ describe('type: string', () => {
})

test('group add', async () => {
app.receiveGroupRequest(321, 'add')
app.receiveGroupRequest('add', 321)
await sleep(0)
app.shouldHaveLastRequest('set_group_add_request', { approve: false, reason: 'bar' })
})

test('group invite', async () => {
app.receiveGroupRequest(321, 'invite')
app.receiveGroupRequest('invite', 321)
await sleep(0)
app.shouldHaveLastRequest('set_group_add_request', { approve: false, reason: 'baz' })
})
Expand All @@ -79,13 +79,13 @@ describe('type: boolean', () => {
})

test('group add', async () => {
app.receiveGroupRequest(321, 'add')
app.receiveGroupRequest('add', 321)
await sleep(0)
app.shouldHaveLastRequest('set_group_add_request', { approve: false })
})

test('group invite', async () => {
app.receiveGroupRequest(321, 'invite')
app.receiveGroupRequest('invite', 321)
await sleep(0)
app.shouldHaveLastRequest('set_group_add_request', { approve: false })
})
Expand All @@ -109,13 +109,13 @@ describe('type: function', () => {
})

test('group add', async () => {
app.receiveGroupRequest(321, 'add')
app.receiveGroupRequest('add', 321)
await sleep(0)
app.shouldHaveLastRequest('set_group_add_request', { approve: true })
})

test('group invite', async () => {
app.receiveGroupRequest(321, 'invite')
app.receiveGroupRequest('invite', 321)
await sleep(0)
app.shouldHaveLastRequest('set_group_add_request', { approve: true })
})
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class MockedApp extends App {
this.receive({ postType: 'request', requestType: 'friend', userId, flag })
}

receiveGroupRequest (userId: number, subType: 'add' | 'invite', groupId = 10000, flag = 'flag') {
receiveGroupRequest (subType: 'add' | 'invite', userId: number, groupId = 10000, flag = 'flag') {
this.receive({ postType: 'request', requestType: 'group', subType, userId, groupId, flag })
}

Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/tests/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Receiver', () => {
test('receiveGroupRequest', async () => {
const mock = jest.fn()
app.receiver.on('request/group/add', mock)
app.receiveGroupRequest(123, 'add')
app.receiveGroupRequest('add', 123)
expect(mock).toBeCalledTimes(1)
expect(mock).toBeCalledWith({
$approve: expect.anything(),
Expand Down

0 comments on commit 16fd63e

Please sign in to comment.