Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
test: refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
severo committed Jan 21, 2020
1 parent 893e00a commit d0cdf6e
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions src/socket.io/socket.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,27 @@ describe('Server', () => {
updateUserNameEventArgs
)

Promise.all([
new Promise((resolve, reject) =>
client.on('connect', () => {
// act
client.emit(
UpdateUserNameEvent.eventName,
updateUserNameEvent.data,
(value: UpdateUserNameAckArgs) => {
try {
// assert
expect(value).to.not.be.undefined
expect(value.updated).to.be.false
expect(value.error).to.not.be.undefined
new Promise(resolve =>
client.on('connect', () => {
// act
client.emit(
UpdateUserNameEvent.eventName,
updateUserNameEvent.data,
(value: UpdateUserNameAckArgs) => resolve(value)
)
})
)
.then((value: UpdateUserNameAckArgs) => {
// assert
expect(value).to.not.be.undefined
expect(value).to.have.property('updated', false)
expect(value).to.have.property('error')
expect(value.error).to.have.property('name', 'Error')
expect(value.error).to.have.property(
'message',
`Parameter <Object>.${expectedParameter} is required`
)

expect(value.error.name).to.equal('Error')
expect(value.error.message).to.equal(
`Parameter <Object>.${expectedParameter} is required`
)
resolve()
} catch (e) {
reject(e)
}
}
)
})
),
])
.then(() => {
const logs = mockLogger.getInfoLogs()
logs.should.include.something.that.equals(
`User name could not be updated - Parameter <Object>.${expectedParameter} is required`
Expand Down

0 comments on commit d0cdf6e

Please sign in to comment.