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

Commit

Permalink
Merge bc1227b into b78eae0
Browse files Browse the repository at this point in the history
  • Loading branch information
tboeckmann committed Sep 3, 2019
2 parents b78eae0 + bc1227b commit 7ee10e1
Show file tree
Hide file tree
Showing 14 changed files with 440 additions and 98 deletions.
43 changes: 10 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 83 additions & 53 deletions src/app/inbox/inbox-message/inbox-message.component.html
Original file line number Diff line number Diff line change
@@ -1,64 +1,94 @@
<div class="clearfix mb-xs">
<a class="btn btn-outline-secondary btn-sm float-left" id="back-btn" (click)="returnToInboxMessages()">
<i class="fa fa-angle-left fa-lg"></i> Back To Messages
</a>
</div>
<hr>
<div>
<h4>{{currentMessage.subject}}</h4>
<div class="message-actions float-right">
<div class="message-action">
<button class="btn btn-sm btn-outline-secondary" type="button" (click)="modalWindowMailInfo.show()"><i class="fa fa-info-circle"></i></button>
</div>
<div class="message-action">
<div class="btn-group">
<button id="reply" class="btn btn-sm btn-outline-secondary" (click)="replyToMsg()">
<i class="fa fa-reply"></i> Reply
</button>
</div>
<a class="btn btn-outline-secondary btn-sm float-left" id="back-btn" (click)="returnToInboxMessages()">
<i class="fa fa-angle-left fa-lg"></i> Back To Messages
</a>
</div>
<hr>
<div>
<h4>{{currentMessage.subject}}</h4>
<div class="message-actions float-right">
<div class="message-action">
<button class="btn btn-sm btn-outline-secondary" type="button" (click)="modalWindowMailInfo.show()"><i
class="fa fa-info-circle"></i></button>
</div>

<div class="message-action">
<div class="btn-group">
<button id="reply" class="btn btn-sm btn-outline-secondary" (click)="replyToMsg()">
<i class="fa fa-reply"></i> Reply
</button>
</div>
</div>
</div>
<div id="message" class="clearfix">
<div id="message-header">
<span class="float-left">
<img class="rounded-circle message-identicon" src="{{currentMessage.senderIdenticon}}" alt="">
</div>
<div id="message" class="clearfix">
<div id="message-header">
<span class="float-left">
<img class="rounded-circle message-identicon" src="{{currentMessage.senderIdenticon}}" alt="">
</span>
<div class="float-left">
<!-- From name defined -->
<span *ngIf="messageNameRecords[parseAddressFromMailchain(currentMessage.headers.from)] != undefined">
<span>
From:&nbsp;{{messageNameRecords[parseAddressFromMailchain(currentMessage.headers.from)]}}
</span>
<br>
<span>{{currentMessage.headers.from}}</span>
</span>
<div class="float-left">
From: <strong>{{currentMessage.headers.from}}</strong>
<span class="message-to">To: {{currentMessage.headers.to}}</span>
</div>
<div class="float-right">
{{currentMessage.headers.date}}
</div>
<!-- ./ From name defined -->
<!-- From name not defined -->
<span *ngIf="messageNameRecords[parseAddressFromMailchain(currentMessage.headers.from)] == undefined">
<span>From:&nbsp;{{currentMessage.headers.from}}</span>
</span>
<!-- ./ From name not defined -->
<br>
<!-- To name defined -->
<span class="message-to"
*ngIf="messageNameRecords[parseAddressFromMailchain(currentMessage.headers.to)] != undefined">
<span>
To:&nbsp;{{messageNameRecords[parseAddressFromMailchain(currentMessage.headers.to)]}}
</span>
<br>
<span>{{currentMessage.headers.to}}</span>
</span>
<!-- ./ To name defined -->
<!-- To name not defined -->
<span class="message-to"
*ngIf="messageNameRecords[parseAddressFromMailchain(currentMessage.headers.to)] == undefined">
<span>To:&nbsp;{{currentMessage.headers.to}}</span>
</span>
<!-- ./ To name not defined -->
</div>
<div class="float-right">
{{currentMessage.headers.date}}
</div>
</div>
<hr>
<div class="message-body">
<pre class="pre-inherit" [innerText]="currentMessage.body"></pre>
</div>


<!-- modalWindowMailInfo -->
<div bsModal #modalWindowMailInfo="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header flex-column">
<button (click)="modalWindowMailInfo.hide()" aria-label="Close" class="close ml-auto" type="button">
<span aria-hidden="true">×</span>
</button>
<div class="col-12 text-center">
<h3 class="modal-title" id="mailModal">Raw Message Details</h3>
</div>
</div>
<div class="modal-body">
<pre>{{currentMessage | json}}</pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" (click)="modalWindowMailInfo.hide()">Close</button>
</div>
<hr>
<div class="message-body">
<pre class="pre-inherit" [innerText]="currentMessage.body"></pre>
</div>


<!-- modalWindowMailInfo -->
<div bsModal #modalWindowMailInfo="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header flex-column">
<button (click)="modalWindowMailInfo.hide()" aria-label="Close" class="close ml-auto" type="button">
<span aria-hidden="true">×</span>
</button>
<div class="col-12 text-center">
<h3 class="modal-title" id="mailModal">Raw Message Details</h3>
</div>
</div>
<div class="modal-body">
<pre>{{currentMessage | json}}</pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" (click)="modalWindowMailInfo.hide()">Close</button>
</div>
</div>
</div>
<!-- end modalWindowMailInfo -->
</div>
<!-- end modalWindowMailInfo -->
4 changes: 4 additions & 0 deletions src/app/inbox/inbox-message/inbox-message.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@
.message-to {
display: block;
}

.message-to{
padding-top: 5px;
}
69 changes: 67 additions & 2 deletions src/app/inbox/inbox-message/inbox-message.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,66 @@ import { InboxMessageComponent } from './inbox-message.component';
import { ModalModule } from 'ngx-bootstrap/modal';
import { MailchainTestService } from 'src/app/test/test-helpers/mailchain-test.service';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpHelpersService } from 'src/app/services/helpers/http-helpers/http-helpers.service';
import { MailchainService } from 'src/app/services/mailchain/mailchain.service';
import { of } from 'rxjs';
import { NameserviceService } from 'src/app/services/mailchain/nameservice/nameservice.service';
import { HttpClientModule } from '@angular/common/http';

describe('InboxMessageComponent', () => {

let component: InboxMessageComponent;
let fixture: ComponentFixture<InboxMessageComponent>;
let mailchainService: MailchainService;
let nameserviceService: NameserviceService;

let mailchainTestService: MailchainTestService

const address1 = "0x0000000000000000000000000000000000000001"
const mcAddress1 = "<" + address1 + "@ropsten.ethereum>"
const address2 = "0x0000000000000000000000000000000000000002"
const mcAddress2 = "<" + address2 + "@ropsten.ethereum>"

/**
* Resolves address1: myname.eth
* Throws 404 error for address2
*/
class NameserviceServiceStub {
resolveAddress(protocol,network,value) {
if (value == address1) {
return of(
{
"body": { name: "myname.eth" },
"ok": true
}
)
} else {
return of({"status": 404})
}
}
}

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
InboxMessageComponent,
],
providers: [],
providers: [
HttpHelpersService,
MailchainService,
{ provide: NameserviceService, useClass: NameserviceServiceStub },
],
imports: [
ModalModule.forRoot(),
RouterTestingModule
RouterTestingModule,
HttpClientModule,

]
})
.compileComponents();
mailchainTestService = TestBed.get(MailchainTestService);
nameserviceService = TestBed.get(NameserviceService);
mailchainService = TestBed.get(MailchainService);

}));

Expand Down Expand Up @@ -59,4 +99,29 @@ describe('InboxMessageComponent', () => {
})
});

describe('ngOnInit', () => {
describe('resolveNamesFromMessage', () => {
it('should resolve the To field when there is a resolvable name', () => {
component.currentMessage["headers"]["to"] = mcAddress1
component.ngOnInit()
expect(component.messageNameRecords[address1]).toEqual('myname.eth')
})
it('should NOT resolve the To field when there is NOT a resolvable name', () => {
component.currentMessage["headers"]["to"] = mcAddress2
component.ngOnInit()
expect(component.messageNameRecords[address2]).toEqual(undefined)
})
it('should resolve the From field when there is a resolvable name', () => {
component.currentMessage["headers"]["from"] = mcAddress1
component.ngOnInit()
expect(component.messageNameRecords[address1]).toEqual('myname.eth')
})
it('should NOT resolve the From field when there is NOT a resolvable name', () => {
component.currentMessage["headers"]["from"] = mcAddress2
component.ngOnInit()
expect(component.messageNameRecords[address2]).toEqual(undefined)
})
});
});

});
Loading

0 comments on commit 7ee10e1

Please sign in to comment.