Skip to content

Commit

Permalink
fix(ng9): update tests to use TestBed.inject
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlking committed Feb 10, 2020
1 parent 7449d24 commit 48dd5b2
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 180 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy to GitHub Pages via angular-cli-ghpages

on:
pull_request:
branches:
- master

push:
branches:
- master

jobs:
build_lint_test_deploy:
runs-on: ubuntu-latest

steps:
- name: Build the app
uses: actions/checkout@v2

- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Install
run: CYPRESS_INSTALL_BINARY=0 yarn install

- name: Lint
if: success()
run: yarn run lint

- name: Test
if: success()
run: yarn run test

- name: Deploy
if: success() && github.event_name == 'push'
run: yarn run deploy
env:
CI: true
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"ms-azuretools.vscode-docker",
"donjayamanne.githistory",
"eamodio.gitlens",
"humao.rest-client"
"humao.rest-client",
"nrwl.angular-console",
"angular.ng-template",
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode"
]
}
4 changes: 4 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
"builder": "ngx-deploy-npm:deploy",
"options": {
"access": "public"
// "cname": "xmlking.gitbook.io",
// "name": "deploymock",
// "email": "sumo@demo.com",
// "message": "Deploying: ngx-starter-kit"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@nestjs/platform-express": "6.11.6",
"@nestjs/platform-socket.io": "6.11.6",
"@nestjs/swagger": "4.2.6",
"@nestjs/terminus": "6.5.5",
"@nestjs/terminus": "6.5.6",
"@nestjs/typeorm": "6.2.0",
"@nestjs/websockets": "6.11.6",
"@nestjsx/crud": "4.4.1",
Expand Down
22 changes: 11 additions & 11 deletions libs/auth/src/lib/auth.state.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { NgxsModule, Store } from '@ngxs/store';
import { async, TestBed } from '@angular/core/testing';
import { AuthState } from './auth.state';
import { NgxsModule, Store } from '@ngxs/store';
import { LogoutSuccess } from './auth.actions';
import { AuthState } from './auth.state';

describe('Auth', () => {
let store: Store;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([AuthState])],
}).compileComponents();
store = TestBed.get(Store);
TestBed
.configureTestingModule({
imports: [NgxsModule.forRoot([AuthState])],
})
.compileComponents();
store = TestBed.inject(Store);
}));

it('it toggles feed', () => {
store.dispatch(new LogoutSuccess());
store
.select(state => state.auth.isLoggedIn)
.subscribe(isLoggedIn => {
expect(isLoggedIn).toBe(false);
});
store.select(state => state.auth.isLoggedIn).subscribe(isLoggedIn => {
expect(isLoggedIn).toBe(false);
});
});
});
3 changes: 1 addition & 2 deletions libs/core/src/lib/services/feature.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { TestBed } from '@angular/core/testing';

import { FeatureService } from './feature.service';

describe('FeatureService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: FeatureService = TestBed.get(FeatureService);
const service: FeatureService = TestBed.inject(FeatureService);
expect(service).toBeTruthy();
});
});
4 changes: 2 additions & 2 deletions libs/core/src/lib/services/google-analytics.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { TestBed } from '@angular/core/testing';

import { GoogleAnalyticsService } from './google-analytics.service';

describe('GoogleAnalyticsService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: GoogleAnalyticsService = TestBed.get(GoogleAnalyticsService);
const service: GoogleAnalyticsService =
TestBed.inject(GoogleAnalyticsService);
expect(service).toBeTruthy();
});
});
5 changes: 3 additions & 2 deletions libs/core/src/lib/services/push-notification.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TestBed } from '@angular/core/testing';

import { PushNotificationService } from './push-notification.service';


describe('PushNotificationService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: PushNotificationService = TestBed.get(PushNotificationService);
const service: PushNotificationService =
TestBed.inject(PushNotificationService);
expect(service).toBeTruthy();
});
});
4 changes: 2 additions & 2 deletions libs/core/src/lib/state/profile.state.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TestBed, async } from '@angular/core/testing';
import { async, TestBed } from '@angular/core/testing';
import { NgxsModule, Store } from '@ngxs/store';
import { ProfileState, ProfileStateModel } from './profile.state';

Expand All @@ -8,7 +8,7 @@ describe('Profile state', () => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([ProfileState])],
}).compileComponents();
store = TestBed.get(Store);
store = TestBed.inject(Store);
}));

it('should create an empty state', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from "@angular/core";
import { Injectable } from '@angular/core';
export interface IPoint {
x: number;
y: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('ViewportService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: ViewportService = TestBed.get(ViewportService);
const service: ViewportService = TestBed.inject(ViewportService);
expect(service).toBeTruthy();
});
});
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"prebuild": "rimraf dist coverage",
"build": "ng build",
"build:prod": "ng build webapp -c=production",
"deploy": "ng deploy --base-href=/ngx-starter-kit/ --configuration=mock",
"deploy:mock": "ng deploy --base-href=/ngx-starter-kit/ --configuration=mock",
"bundle-report": "ng build -c=production --stats-json && webpack-bundle-analyzer dist/apps/webapp/stats-es2015.json",
"report-coverage": "codecov --token=$CODECOV_TOKEN",
Expand Down Expand Up @@ -120,7 +121,7 @@
"@angular/platform-browser-dynamic": "9.0.0",
"@angular/router": "9.0.0",
"@angular/service-worker": "9.0.0",
"@fortawesome/angular-fontawesome": "0.5.0",
"@fortawesome/angular-fontawesome": "0.6.0",
"@fortawesome/fontawesome-svg-core": "1.2.27",
"@fortawesome/free-brands-svg-icons": "5.12.1",
"@fortawesome/free-solid-svg-icons": "5.12.1",
Expand Down Expand Up @@ -164,7 +165,7 @@
"ngx-filepond": "5.0.1",
"ngx-page-scroll": "7.0.0",
"ngx-page-scroll-core": "7.0.0",
"ngx-perfect-scrollbar": "8.0.0",
"ngx-perfect-scrollbar": "9.0.0",
"rxjs": "6.5.4",
"screenfull": "5.0.1",
"smooth-scrollbar": "8.5.1",
Expand Down Expand Up @@ -192,7 +193,7 @@
"loaders.css": "0.1.2",
"ng-packagr": "^9.0.0",
"ngx-deploy-npm": "1.2.0",
"rimraf": "3.0.1",
"rimraf": "3.0.2",
"ts-loader": "6.2.1",
"ts-node": "8.6.2",
"tsconfig-paths": "3.9.0",
Expand Down

0 comments on commit 48dd5b2

Please sign in to comment.