diff --git a/src/app/inbox/inbox-compose/inbox-compose.component.spec.ts b/src/app/inbox/inbox-compose/inbox-compose.component.spec.ts index c4a0ea8..a081de5 100644 --- a/src/app/inbox/inbox-compose/inbox-compose.component.spec.ts +++ b/src/app/inbox/inbox-compose/inbox-compose.component.spec.ts @@ -291,6 +291,19 @@ describe('InboxComposeComponent', () => { component.recipientResolve(event) expect(component.currentRecipientValue).toEqual("alice.eth") }) + it('should trim whitespace from currentRecipientValue', () => { + let event = { target: { value: " alice.eth " } } + + component.recipientResolve(event) + expect(component.currentRecipientValue).toEqual("alice.eth") + }) + it('should trim whitespace from the call to recipientAddressChanged', () => { + let event = { target: { value: " alice.eth " } } + spyOn(component.recipientAddressChanged, 'next').and.callThrough() + + component.recipientResolve(event) + expect(component.recipientAddressChanged.next).toHaveBeenCalledWith("alice.eth") + }) xit('should call the resolveAddress thru the private recipientAddressChanged subscription next function with the event.target.value', () => { let event = { target: { value: "alice.eth" } } spyOn(component, 'resolveAddress').and.callThrough() diff --git a/src/app/inbox/inbox-compose/inbox-compose.component.ts b/src/app/inbox/inbox-compose/inbox-compose.component.ts index 7d3d216..7a5a859 100644 --- a/src/app/inbox/inbox-compose/inbox-compose.component.ts +++ b/src/app/inbox/inbox-compose/inbox-compose.component.ts @@ -39,7 +39,7 @@ export class InboxComposeComponent implements OnInit { private subscription public currentRecipientValue - private recipientAddressChanged = new Subject(); + public recipientAddressChanged = new Subject(); public recipientLoadingIcon = "" public recipientLoadingText = "" public messageToField = "" @@ -136,17 +136,19 @@ export class InboxComposeComponent implements OnInit { * @param event the event from keyup */ public recipientResolve(event) { - if (event.target.value == "") { + let eventVal = event.target.value.trim(); + if (eventVal == "") { this.setRecipientLoadingIcon("clear") this.setRecipientLoadingText() this.resetModelToField() - } else if (this.currentRecipientValue != event.target.value) { + } else if (this.currentRecipientValue != eventVal) { this.setRecipientLoadingIcon("loading") this.setRecipientLoadingText() this.resetModelToField() } - this.currentRecipientValue = event.target.value - this.recipientAddressChanged.next(event.target.value); + this.currentRecipientValue = eventVal + this.recipientAddressChanged.next(eventVal); + } /**