Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACRFD-56: Tests + Misc Cleanup #392

Merged
merged 1 commit into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-admin --fix --format=stylish",
"prettier --write --loglevel warn",
"git add"
],
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,26 @@ npm run lint-fix

[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`

```
npm run tests
```
* Run the unit tests with `watch=false`
* Run the unit tests with `watch=false` and run the coverage report

View the coverage report at `./coverage/index.html`
```
npm run tests-ci
```
* 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
16 changes: 8 additions & 8 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-admin": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
Expand Down Expand Up @@ -54,26 +54,26 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "base-app2:build",
"browserTarget": "nrts-prc-admin:build",
"port": 4200
},
"configurations": {
"production": {
"browserTarget": "base-app2:build:production"
"browserTarget": "nrts-prc-admin:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "base-app2:build"
"browserTarget": "nrts-prc-admin:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"karmaConfig": "src/karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [
Expand Down Expand Up @@ -103,7 +103,7 @@
}
}
},
"base-app2-e2e": {
"nrts-prc-admin-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
Expand All @@ -112,7 +112,7 @@
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "base-app2:serve"
"devServerTarget": "nrts-prc-admin:serve"
}
},
"lint": {
Expand All @@ -127,7 +127,7 @@
}
}
},
"defaultProject": "base-app2",
"defaultProject": "nrts-prc-admin",
"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-admin App', () => {
let page: BaseApp2Page;

beforeEach(() => {
Expand Down
42 changes: 0 additions & 42 deletions karma.conf.js

This file was deleted.

42 changes: 23 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "base-app",
"name": "nrts-prc-admin",
"version": "0.0.0",
"license": "Apache-2.0",
"scripts": {
Expand All @@ -9,18 +9,21 @@
"postinstall": "ng build --prod --deploy-url /admin/ --base-href /admin/",
"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-admin --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-admin --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"
},
"dependencies": {
"@angular/animations": "6.1.10",
"@angular/cdk": "6.4.7",
Expand All @@ -29,8 +32,8 @@
"@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",
"@auth0/angular-jwt": "2.1.0",
"@ng-bootstrap/ng-bootstrap": "3.3.1",
Expand All @@ -40,28 +43,28 @@
"core-js": "2.6.8",
"file-saver": "2.0.2",
"hammerjs": "2.0.8",
"json2csv": "4.5.1",
"json2csv": "4.5.3",
"keycloak-angular": "3.0.3",
"leaflet": "1.5.1",
"linkify-it": "2.1.0",
"lodash": "4.17.11",
"moment": "2.24.0",
"mygovbc-bootstrap-theme": "0.4.1",
"ng-inline-svg": "8.5.1",
"ng2-bootstrap-modal": "1.0.1",
"ngx-pagination": "3.2.1",
"ng-inline-svg": "8.5.1",
"rxjs": "6.5.2",
"rxjs": "6.5.3",
"web-animations-js": "2.3.1",
"xlsx": "0.14.3",
"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",
"@types/arcgis-js-api": "4.11.0",
"@angular/compiler": "6.1.10",
"@types/arcgis-js-api": "4.12.0",
"@types/file-saver": "2.0.1",
"@types/jasmine": "3.3.13",
"@types/json2csv": "4.5.0",
Expand All @@ -70,23 +73,24 @@
"@types/node": "10.14.7",
"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",
"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 @@ -9,11 +9,13 @@ describe('AddEditUserComponent', () => {
let component: AddEditUserComponent;
let fixture: ComponentFixture<AddEditUserComponent>;

const userServiceSpy = jasmine.createSpyObj('UserService', ['add', 'save']);

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AddEditUserComponent],
imports: [FormsModule],
providers: [{ provide: DialogService }, { provide: UserService }]
providers: [DialogService, { provide: UserService, useValue: userServiceSpy }]
}).compileComponents();
}));

Expand Down
2 changes: 1 addition & 1 deletion src/app/administration/users/users.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('UsersComponent', () => {
TestBed.configureTestingModule({
declarations: [UsersComponent],
imports: [NgbModule],
providers: [{ provide: DialogService }, { provide: UserService, useValue: mockUserService }]
providers: [DialogService, { provide: UserService, useValue: mockUserService }]
}).compileComponents();
}));

Expand Down
5 changes: 3 additions & 2 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FooterComponent } from './footer/footer.component';
import { ApiService } from 'app/services/api';
import { KeycloakService } from 'app/services/keycloak.service';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientTestingModule } from '@angular/common/http/testing';

describe('AppComponent', () => {
beforeEach(async(() => {
Expand All @@ -18,8 +19,8 @@ describe('AppComponent', () => {

TestBed.configureTestingModule({
declarations: [AppComponent, HeaderComponent, FooterComponent],
imports: [RouterTestingModule, BrowserAnimationsModule],
providers: [{ provide: ApiService }, { provide: KeycloakService, useValue: mockKeycloakService }]
imports: [RouterTestingModule, HttpClientTestingModule, BrowserAnimationsModule],
providers: [ApiService, { provide: KeycloakService, useValue: mockKeycloakService }]
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,39 @@ import { ApplicationAddEditComponent } from './application-add-edit.component';
import { FileUploadComponent } from 'app/file-upload/file-upload.component';
import { RouterTestingModule } from '@angular/router/testing';
import { MatSnackBar } from '@angular/material';
import { ApiService } from 'app/services/api';
import { ApplicationService } from 'app/services/application.service';
import { CommentPeriodService } from 'app/services/commentperiod.service';
import { DecisionService } from 'app/services/decision.service';
import { DocumentService } from 'app/services/document.service';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { SearchComponent } from 'app/search/search.component';

xdescribe('ApplicationAddEditComponent', () => {
describe('ApplicationAddEditComponent', () => {
let component: ApplicationAddEditComponent;
let fixture: ComponentFixture<ApplicationAddEditComponent>;

const matSnackBarSpy = jasmine.createSpyObj('MatSnackBar', ['open', 'dismiss']);
const applicationServiceSpy = jasmine.createSpyObj('ApplicationService', ['save']);
const commentPeriodServiceSpy = jasmine.createSpyObj('CommentPeriodService', ['add', 'save', 'publish']);
const decisionServiceSpy = jasmine.createSpyObj('DecisionService', ['add', 'save', 'publish', 'delete']);
const documentServiceSpy = jasmine.createSpyObj('DocumentService', ['add', 'save', 'publish']);

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [FormsModule, NgbModule, RouterTestingModule],
declarations: [ApplicationAddEditComponent, FileUploadComponent],
imports: [
FormsModule,
NgbModule,
HttpClientTestingModule,
RouterTestingModule.withRoutes([{ path: 'search', component: SearchComponent }])
],
declarations: [ApplicationAddEditComponent, FileUploadComponent, SearchComponent],
providers: [
{ provide: DialogService },
{ provide: MatSnackBar },
{ provide: ApiService },
{ provide: ApplicationService },
{ provide: CommentPeriodService },
{ provide: DecisionService },
{ provide: DocumentService }
DialogService,
{ provide: MatSnackBar, useValue: matSnackBarSpy },
{ provide: ApplicationService, useValue: applicationServiceSpy },
{ provide: CommentPeriodService, useValue: commentPeriodServiceSpy },
{ provide: DecisionService, useValue: decisionServiceSpy },
{ provide: DocumentService, useValue: documentServiceSpy }
]
}).compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Application } from 'app/models/application';
import { CommentPeriod } from 'app/models/commentperiod';
import { Document } from 'app/models/document';
import { Decision } from 'app/models/decision';
import { ApiService } from 'app/services/api';
import { ApplicationService } from 'app/services/application.service';
import { CommentPeriodService } from 'app/services/commentperiod.service';
import { DecisionService } from 'app/services/decision.service';
Expand Down Expand Up @@ -51,7 +50,6 @@ export class ApplicationAddEditComponent implements OnInit, AfterViewInit, OnDes
private router: Router,
// private location: Location,
public snackBar: MatSnackBar,
public api: ApiService, // also also used in template
private applicationService: ApplicationService,
private commentPeriodService: CommentPeriodService,
private dialogService: DialogService,
Expand Down
Loading