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

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
tboeckmann committed Dec 17, 2019
1 parent bafabc8 commit 3c79f17
Show file tree
Hide file tree
Showing 59 changed files with 963 additions and 994 deletions.
2 changes: 1 addition & 1 deletion e2e/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports.config = {
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
print: function () { }
},
onPrepare() {
require('ts-node').register({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
"tslint": "~5.11.0",
"typescript": "~3.5.3"
}
}
}
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ const routes: Routes = [
providers: [HttpHelpersService],
exports: [RouterModule]
})
export class AppRoutingModule {}
export class AppRoutingModule { }
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<footer class="footer">
<div class="container">
<span class="text-muted">
Made by <a href="https://mailchain.xyz" target="_blank">Mailchain</a>
Made by <a href="https://mailchain.xyz" target="_blank">Mailchain</a>
</span>
<span class="text-muted pull-right">Inbox Version: {{version}} (API Version: {{apiVersion}})</span>
</div>
Expand Down
78 changes: 39 additions & 39 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { HttpHelpersService } from './services/helpers/http-helpers/http-helpers
declarations: [ModalConnectivityErrorComponent],
entryComponents: [ModalConnectivityErrorComponent]
})
export class FakeModalConnectivityErrorModule {}
export class FakeModalConnectivityErrorModule { }
// End workaround

describe('AppComponent', () => {
Expand Down Expand Up @@ -60,114 +60,114 @@ describe('AppComponent', () => {
});

describe('ngOnInit', () => {

describe('setApiVersion', () => {
it('set the API version as part of ngOnInit (after other calls have been made)', async() => {
it('set the API version as part of ngOnInit (after other calls have been made)', async () => {
expect(component.apiVersion).toEqual("")
let ver = "1.4.1"
component.apiVersionInfo["client-version"] = ver
component.setApiVersion()

expect(component.apiVersion).toEqual(ver)
});
});

});

describe('handleApiAvailability', () => {
it('should handle connection refused error', async() => {
it('should handle connection refused error', async () => {
spyOn(connectivityService, 'getApiAvailability').and.returnValue(mailchainTestService.getApiAvailabilityConnectionRefused())

expect(component.errorTitle).toEqual("")
expect(component.errorMessage).toEqual("")

await component.handleApiAvailability()

expect(component.errorTitle).toEqual(errorMessages.clientNotRunningErrorTitle)
expect(component.errorMessage).toEqual(errorMessages.clientNotRunningErrorMessage)

});
it('should handle unknown error', async() => {

it('should handle unknown error', async () => {
spyOn(connectivityService, 'getApiAvailability').and.returnValue(mailchainTestService.getApiAvailabilityErrorUnknown())

expect(component.errorTitle).toEqual("")
expect(component.errorMessage).toEqual("")

await component.handleApiAvailability()

expect(component.errorTitle).toEqual(errorMessages.unknownErrorTitle)
expect(component.errorMessage).toEqual(errorMessages.unknownErrorMessage)

});

it('should handle status ok, with 0 addresses, error', async() => {
it('should handle status ok, with 0 addresses, error', async () => {
spyOn(connectivityService, 'getApiAvailability').and.returnValue(mailchainTestService.getApiAvailabilitySuccessNoAddresses())

expect(component.errorTitle).toEqual("")
expect(component.errorMessage).toEqual("")

await component.handleApiAvailability()

expect(component.errorTitle).toEqual(errorMessages.accountConfigurationErrorTitle)
expect(component.errorMessage).toEqual(errorMessages.accountConfigurationErrorMessage)

});

it('should handle status ok, with addresses', async() => {
it('should handle status ok, with addresses', async () => {
spyOn(connectivityService, 'getApiAvailability').and.returnValue(mailchainTestService.getApiAvailabilitySuccess())

expect(component.errorTitle).toEqual("")
expect(component.errorMessage).toEqual("")

await component.handleApiAvailability()

expect(component.errorTitle).toEqual("")
expect(component.errorMessage).toEqual("")

});
});

describe('handleWebConnectivity', () => {
xit('should handle an error fetching version info', () => {
// TODO handle error
});
it('should show an error if the client-error-status field is defined', async() => {
});
it('should show an error if the client-error-status field is defined', async () => {
spyOn(connectivityService, 'getVersionStatus').and.returnValue(mailchainTestService.apiVersionInfoClientError())

expect(component.errorTitle).toEqual("")
expect(component.errorMessage).toEqual("")

await component.handleWebConnectivity()

expect(component.errorTitle).toEqual(errorMessages.connectionErrorTitle)
expect(component.errorMessage).toEqual("7 Some Client Error")
});
it('should show an error if the release-error-status field is defined', async() => {

});
it('should show an error if the release-error-status field is defined', async () => {
spyOn(connectivityService, 'getVersionStatus').and.returnValue(mailchainTestService.apiVersionInfoReleaseError())

expect(component.errorTitle).toEqual("")
expect(component.errorMessage).toEqual("")

await component.handleWebConnectivity()

expect(component.errorTitle).toEqual(errorMessages.connectionErrorTitle)
expect(component.errorMessage).toEqual("5 Some Release Error")
});

it('should show an error if the api version is outdated', async() => {
it('should show an error if the api version is outdated', async () => {
spyOn(connectivityService, 'getVersionStatus').and.returnValue(mailchainTestService.apiVersionInfoOutdated())

expect(component.errorTitle).toEqual("")
expect(component.errorMessage).toEqual("")

await component.handleWebConnectivity()

expect(component.errorTitle).toEqual(errorMessages.updateAvailableTitle)
expect(component.errorMessage).toEqual('<p>Your Mailchain client version is 1.4.1. Please upgrade it to version 1.4.2 to ensure things work as expected.</p><p>Please visit <a href="https://docs.mailchain.xyz/troubleshooting/common-inbox-errors" target="_blank">Docs: common inbox errors</a> to see how to fix this.</p>')
});
});

});

describe('handleErrorOnPage', () => {
Expand All @@ -178,8 +178,8 @@ describe('AppComponent', () => {
let title = "Error Title"
let msg = "Error Message"

component.handleErrorOnPage(title, msg)
component.handleErrorOnPage(title, msg)

expect(component.errorTitle).toEqual(title)
expect(component.errorMessage).toEqual(msg)

Expand All @@ -193,16 +193,16 @@ describe('AppComponent', () => {
let origMsg = "Error is already in view"
let title = "Error Title"
let msg = "Error Message"

component.errorTitle = origTitle
component.errorMessage = origMsg

component.handleErrorOnPage(title, msg)

expect(component.errorTitle).toEqual(origTitle)
expect(component.errorMessage).toEqual(origMsg)

});
});

});
38 changes: 19 additions & 19 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ export class AppComponent implements OnInit {
private connectivityService: ConnectivityService,
private modalService: BsModalService
) {

}

public setApiVersion() {
this.apiVersion = this.apiVersionInfo["client-version"]
}

public async ngOnInit(){
public async ngOnInit() {
await this.handleApiAvailability()
await this.handleWebConnectivity()
this.setApiVersion()
this.setApiVersion()
}

/**
Expand All @@ -44,7 +44,7 @@ export class AppComponent implements OnInit {
*/
public async handleApiAvailability() {
this.apiConnectivityInfo = await this.connectivityService.getApiAvailability();

if (this.apiConnectivityInfo["status"] == "error") {
switch (this.apiConnectivityInfo["code"]) {
case 0:
Expand All @@ -54,14 +54,14 @@ export class AppComponent implements OnInit {
errorMessages.clientNotRunningErrorMessage
)
break;

default:
// Something else happened
this.handleErrorOnPage(
errorMessages.unknownErrorTitle,
errorMessages.unknownErrorMessage
)
console.warn('please add a new error message for this code',this.apiConnectivityInfo["code"]);
console.warn('please add a new error message for this code', this.apiConnectivityInfo["code"]);
break;
}
} else if (this.apiConnectivityInfo["status"] == "ok") {
Expand All @@ -83,54 +83,54 @@ export class AppComponent implements OnInit {
* handleWebConnectivity
*/
public async handleWebConnectivity() {

try {
this.apiVersionInfo = await this.connectivityService.getVersionStatus();
} catch (error) {
} catch (error) {
this.handleErrorOnPage(
errorMessages.connectionErrorTitle,
error["message"]
)
}
if ( this.apiVersionInfo["errors"] > 0 ) {
}
if (this.apiVersionInfo["errors"] > 0) {

let errorStatusFields = [
"client",
"release"
]

errorStatusFields.forEach(element => {
if (this.apiVersionInfo[`${element}-error-status`] != undefined ) {
if (this.apiVersionInfo[`${element}-error-status`] != undefined) {
this.handleErrorOnPage(
errorMessages.connectionErrorTitle,
errorMessages.connectionErrorTitle,
this.apiVersionInfo[`${element}-error-message`]
)
}
});
}
if ( this.apiVersionInfo["status"] == "outdated" ) {
if (this.apiVersionInfo["status"] == "outdated") {
this.handleErrorOnPage(
errorMessages.updateAvailableTitle,
errorMessages.updateAvailableTitle,
`<p>Your Mailchain client version is ${this.apiVersionInfo["client-version"]}. Please upgrade it to version ${this.apiVersionInfo["release-version"]} to ensure things work as expected.</p><p>Please visit <a href="https://docs.mailchain.xyz/troubleshooting/common-inbox-errors" target="_blank">Docs: common inbox errors</a> to see how to fix this.</p>`
)
}
}

/**
* handleErrorOnPage
*/
public handleErrorOnPage(errorTitle, errorMessage) {

if (this.errorTitle.length == 0 && this.errorMessage.length == 0 ) {
if (this.errorTitle.length == 0 && this.errorMessage.length == 0) {
this.errorTitle = errorTitle
this.errorMessage = errorMessage

const initialState = {
errorTitle: errorTitle,
errorMessage: errorMessage,
};
this.modalConnectivityError = this.modalService.show(ModalConnectivityErrorComponent, {initialState});

this.modalConnectivityError = this.modalService.show(ModalConnectivityErrorComponent, { initialState });
this.modalConnectivityError.content.closeBtnName = 'Close'
}
}
Expand Down
Loading

0 comments on commit 3c79f17

Please sign in to comment.