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

Commit

Permalink
Merge branch 'issues/mailchain/434' into issues/mailchain/release_0.0.38
Browse files Browse the repository at this point in the history
  • Loading branch information
tboeckmann committed Dec 2, 2019
2 parents ae50fe2 + af6ec6d commit ec8e65f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/app/services/mailchain/mailchain.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ describe('MailchainService', () => {
expect(mailchainService.filterMessages(messages, {status: "error", readState: true, headersTo: address2})).toEqual([ messages[1] ])
expect(mailchainService.filterMessages(messages, {status: "error", readState: false, headersTo: address2})).toEqual([ messages[3] ])
})
it('should handle messages returned as null', () => {
expect(mailchainService.filterMessages(null, { status: "ok" })).toEqual([])
expect(mailchainService.filterMessages(null, { readState: true })).toEqual([])
expect(mailchainService.filterMessages(null, { headersTo: address1 })).toEqual([])
})
})

describe('validateEnsName', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/services/mailchain/mailchain.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ export class MailchainService {
let readState = options.readState
let headersTo = options.headersTo
let output = msgsArray
if (status != undefined ) {
output = output.filter(msg => msg.status === status)
if (status != undefined) {
output = output == null ? [] : output.filter(msg => msg.status === status)
}
if (readState != undefined) {
output = output.filter(msg => msg.read === readState)
output = output == null ? [] : output.filter(msg => msg.read === readState)
}
if (headersTo != undefined) {
output = output.filter(msg =>
output = output == null ? [] : output.filter(msg =>
this.parseAddressFromMailchain(msg["headers"]["to"]) == headersTo
)
}
Expand Down

0 comments on commit ec8e65f

Please sign in to comment.