Skip to content

Commit

Permalink
Merge pull request #422 from NickPhura/ACRFD-54
Browse files Browse the repository at this point in the history
ACRFD-54: Tests + Misc Cleanup
  • Loading branch information
NickPhura authored Oct 28, 2019
2 parents 31f6985 + 10902a4 commit 90d75e2
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 108 deletions.
7 changes: 0 additions & 7 deletions .huskyrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"*.ts": [
"ng lint base-app2 --fix --format=stylish",
"ng lint nrts-prc-public --fix --format=stylish",
"prettier --write --loglevel warn",
"git add"
],
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ _Note: Not all linting/formatting errors can be automatically fixed, and will re

[Jasmine](https://jasmine.github.io/), [Karma](https://karma-runner.github.io/latest/index.html), [Protractor](http://www.protractortest.org/)

### Important Note

When viewing test output in the browser, via localhost:9876, Firefox produces somewhat cryptic error output. Chrome doesn't have this issue.

## Run Tests

* Run the unit tests with `watch=true`
Expand All @@ -152,7 +156,7 @@ _Note: Not all linting/formatting errors can be automatically fixed, and will re
```
* Run the end-to-end tests

Before running the tests make sure you are serving the app via `ng serve`.
Before running the tests make sure you are serving the app via `ng serve`
```
npm run e2e
```
Expand Down
14 changes: 7 additions & 7 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
"base-app2": {
"nrts-prc-public": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
Expand Down Expand Up @@ -60,19 +60,19 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "base-app2:build",
"browserTarget": "nrts-prc-public:build",
"port": 4300
},
"configurations": {
"production": {
"browserTarget": "base-app2:build:production"
"browserTarget": "nrts-prc-public:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "base-app2:build"
"browserTarget": "nrts-prc-public:build"
}
},
"test": {
Expand Down Expand Up @@ -116,7 +116,7 @@
}
}
},
"base-app2-e2e": {
"nrts-prc-public-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
Expand All @@ -125,7 +125,7 @@
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "base-app2:serve"
"devServerTarget": "nrts-prc-public:serve"
}
},
"lint": {
Expand All @@ -140,7 +140,7 @@
}
}
},
"defaultProject": "base-app2",
"defaultProject": "nrts-prc-public",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
Expand Down
2 changes: 1 addition & 1 deletion e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseApp2Page } from './app.po';

describe('base-app2 App', () => {
describe('nrts-prc-public App', () => {
let page: BaseApp2Page;

beforeEach(() => {
Expand Down
41 changes: 20 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{
"name": "base-app",
"name": "nrts-prc-public",
"version": "0.0.0",
"license": "Apache-2.0",
"scripts": {
"ng": "ng",
"start": "ng serve -o",
"build": "npm run lint && ng build --prod",
"postinstall": "ng build --prod",
"test": "echo Test suite should be run with `npm run tests` or npm `run tests-ci`",
"test": "echo Test suite should be run with `npm run tests` or `npm run tests-ci`",
"tests": "ng test",
"tests-ci": "ng test --watch=false",
"tests-ci": "ng test --watch=false --code-coverage",
"e2e": "ng e2e",
"lint:ts": "ng lint base-app2 --format=stylish",
"lint:ts": "ng lint nrts-prc-public --format=stylish",
"lint:scss": "stylelint src/**/*.scss",
"lint": "npm-run-all -l -s -c lint:*",
"lint-fix:ts-1": "ng lint base-app2 --fix --format=stylish",
"lint-fix:ts-1": "ng lint nrts-prc-public --fix --format=stylish",
"lint-fix:ts-2": "prettier ./**/*.ts --write --loglevel warn",
"lint-fix:ts": "npm-run-all -l -s -c lint-fix:ts-*",
"lint-fix:scss": "stylelint ./**/*.scss --fix",
"lint-fix": "npm-run-all -l -s -c lint-fix:ts lint-fix:scss"
},
"private": true,
"engines": {
"node": ">= 10.0.0",
"npm": ">= 6.0.0"
Expand All @@ -33,42 +32,42 @@
"@angular/forms": "6.1.10",
"@angular/http": "6.1.10",
"@angular/material": "6.4.7",
"@angular/platform-browser": "6.1.10",
"@angular/platform-browser-dynamic": "6.1.10",
"@angular/platform-browser": "6.1.10",
"@angular/router": "6.1.10",
"@ng-bootstrap/ng-bootstrap": "3.3.1",
"@types/geojson": "7946.0.7",
"@types/leaflet": "1.4.4",
"@types/leaflet.markercluster": "1.4.0",
"@types/leaflet": "1.4.4",
"bootstrap": "4.3.1",
"classlist.js": "1.1.20150312",
"core-js": "2.6.8",
"hammerjs": "2.0.8",
"intl": "1.2.5",
"jquery": "3.4.1",
"leaflet": "1.5.1",
"leaflet.markercluster": "1.4.1",
"leaflet": "1.5.1",
"linkify-it": "2.2.0",
"lodash": "4.17.11",
"moment": "2.24.0",
"mygovbc-bootstrap-theme": "0.4.1",
"ng2-bootstrap-modal": "1.0.1",
"ngx-chips": "1.9.8",
"ngx-page-scroll": "6.0.0",
"ngx-page-scroll-core": "6.0.0",
"ngx-page-scroll": "6.0.0",
"ngx-text-overflow-clamp": "0.0.1",
"object-hash": "1.3.1",
"popper.js": "1.15.0",
"rxjs": "6.5.2",
"rxjs": "6.5.3",
"web-animations-js": "2.3.2",
"zone.js": "0.9.1"
"zone.js": "0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.13.9",
"@angular-devkit/schematics": "0.0.40",
"@angular/cli": "6.2.9",
"@angular/compiler": "6.1.10",
"@angular/compiler-cli": "6.1.10",
"@angular/compiler": "6.1.10",
"@types/arcgis-js-api": "4.12.0",
"@types/jasmine": "3.3.13",
"@types/linkify-it": "2.1.0",
Expand All @@ -77,25 +76,25 @@
"@types/object-hash": "1.3.0",
"codelyzer": "4.5.0",
"husky": "3.0.0",
"jasmine-core": "3.4.0",
"jasmine-core": "3.5.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-chrome-launcher": "3.1.0",
"karma-cli": "2.0.0",
"karma-coverage-istanbul-reporter": "2.0.5",
"karma-jasmine": "2.0.1",
"karma-coverage-istanbul-reporter": "2.1.0",
"karma-jasmine-html-reporter": "1.4.2",
"karma-jasmine": "2.0.1",
"karma-spec-reporter": "0.0.32",
"karma": "4.3.0",
"lint-staged": "9.2.0",
"npm-run-all": "4.1.5",
"ng-mocks": "8.0.0",
"npm-run-all": "4.1.5",
"prettier": "1.18.2",
"protractor": "5.4.2",
"stylelint": "10.1.0",
"stylelint-config-standard": "18.3.0",
"stylelint": "10.1.0",
"ts-node": "8.3.0",
"tslint": "5.18.0",
"tslint-config-prettier": "1.18.0",
"tslint": "5.18.0",
"typescript": "2.9.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ describe('DetailsMapComponent', () => {
let component: DetailsMapComponent;
let fixture: ComponentFixture<DetailsMapComponent>;

const mockFeatureService = jasmine.createSpyObj('FeatureService', ['getByApplicationId', 'getByTantalisId']);
const featureServiceSpy = jasmine.createSpyObj('FeatureService', ['getByApplicationId', 'getByTantalisId']);

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [DetailsMapComponent],
providers: [{ provide: FeatureService, useValue: mockFeatureService }]
providers: [{ provide: FeatureService, useValue: featureServiceSpy }]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DetailsMapComponent);
component = fixture.componentInstance;
component.application = new Application();
mockFeatureService.getByApplicationId.and.returnValue(of([new Feature()]));
featureServiceSpy.getByApplicationId.and.returnValue(of([new Feature()]));
fixture.detectChanges();
});

Expand Down
10 changes: 9 additions & 1 deletion src/app/comment-modal/comment-modal.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ describe('CommentModalComponent', () => {
let component: CommentModalComponent;
let fixture: ComponentFixture<CommentModalComponent>;

const commentServiceSpy = jasmine.createSpyObj('CommentService', ['add']);
const documentServiceSpy = jasmine.createSpyObj('DocumentService', ['add']);

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [CommentModalComponent, MockComponent(FileUploadComponent), MatProgressBar],
imports: [FormsModule],
providers: [NgbActiveModal, DialogService, { provide: CommentService }, { provide: DocumentService }]
providers: [
NgbActiveModal,
DialogService,
{ provide: CommentService, useValue: commentServiceSpy },
{ provide: DocumentService, useValue: documentServiceSpy }
]
}).compileComponents();
}));

Expand Down
2 changes: 1 addition & 1 deletion src/app/confirm/confirm.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('ConfirmComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ConfirmComponent],
providers: [{ provide: DialogService }]
providers: [DialogService]
}).compileComponents();
}));

Expand Down
4 changes: 2 additions & 2 deletions src/app/models/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// this is the data structure as returned by Tantalis
//
export class Feature {
id: string;
_id: string;
type: string;
geometry: {
type: string;
Expand Down Expand Up @@ -40,7 +40,7 @@ export class Feature {
};

constructor(obj?: any) {
this.id = (obj && obj.id) || null;
this._id = (obj && obj._id) || null;
this.type = (obj && obj.type) || null;
this.geometry = (obj && obj.geometry) || null;
this.properties = (obj && obj.properties) || null;
Expand Down
Loading

0 comments on commit 90d75e2

Please sign in to comment.