Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
55 changes: 0 additions & 55 deletions packages/example-app/.angular-cli.json

This file was deleted.

122 changes: 122 additions & 0 deletions packages/example-app/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"example-app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "css"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/example-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "example-app:build"
},
"configurations": {
"production": {
"browserTarget": "example-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "example-app:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"example-app-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "example-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "example-app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "example-app"
}
13 changes: 13 additions & 0 deletions packages/example-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@



module.exports = {
preset: 'jest-preset-angular',
setupTestFrameworkScriptFile: '<rootDir>/src/setupJest.ts',
testMatch: [
"**/*.spec.ts",
],
// moduleFileExtensions: ["ts", "js", "json"],
// collectCoverage: true,
// mapCoverage: true,
}
48 changes: 28 additions & 20 deletions packages/example-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build"
"build": "ng build",
"test": "jest",
"test:watch": "node --inspect=9229 node_modules/jest/bin/jest.js --watch --no-cache",
"test:ci": "jest --runInBand"
},
"engines": {
"node": ">=6.9.5"
Expand All @@ -15,30 +18,35 @@
"@angular-redux/form": "latest",
"@angular-redux/router": "latest",
"@angular-redux/store": "latest",
"@angular/common": "^4.1.0",
"@angular/compiler": "^4.1.0",
"@angular/core": "^4.1.0",
"@angular/forms": "^4.1.0",
"@angular/http": "^4.1.0",
"@angular/platform-browser": "^4.1.0",
"@angular/platform-browser-dynamic": "^4.1.0",
"@angular/router": "^4.1.0",
"@angular/common": "^7.1.0",
"@angular/compiler": "^7.1.0",
"@angular/core": "^7.1.0",
"@angular/forms": "^7.1.0",
"@angular/http": "^7.1.0",
"@angular/platform-browser": "^7.1.0",
"@angular/platform-browser-dynamic": "^7.1.0",
"@angular/router": "^7.1.0",
"core-js": "^2.4.1",
"flux-standard-action": "^1.2.0",
"ramda": "^0.23.0",
"redux": "^3.6.0",
"flux-standard-action": "^2.0.3",
"ramda": "^0.26.0",
"redux": "^4.0.1",
"redux-logger": "^3.0.1",
"redux-observable": "^0.14.1",
"rxjs": "^5.3.0",
"redux-observable": "^1.0.0",
"rxjs": "^6.3.3",
"zone.js": "^0.8.9"
},
"devDependencies": {
"@angular/cli": "1.7.3",
"@angular/compiler-cli": "^4.1.0",
"@types/node": "~6.0.71",
"@angular-devkit/build-angular": "^0.10.6",
"@angular/cli": "^7.0.6",
"@angular/compiler-cli": "^7.1.0",
"@types/jest": "^23.3.9",
"@types/node": "^10.12.10",
"@types/ramda": "^0.25.42",
"@types/redux-logger": "^3.0.0",
"protractor": "~5.1.1",
"ts-node": "~3.0.2",
"typescript": "^2.4.1"
"jest": "^23.6.0",
"jest-preset-angular": "^6.0.1",
"protractor": "^5.4.1",
"ts-node": "^7.0.1",
"typescript": "^3.1.6"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { AnimalListComponent } from './component';

@Component({ selector: 'zoo-animal', template: '' })
class MockAnimalComponent {
@Input() key: string;
@Input() animalType: AnimalType;
@Input() key!: string;
@Input() animalType!: AnimalType;
}

xdescribe('AnimalListComponent', () => {
describe('AnimalListComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AnimalListComponent, MockAnimalComponent],
Expand All @@ -21,7 +21,7 @@ xdescribe('AnimalListComponent', () => {

it("should have as title 'Welcome to the Zoo'", async(() => {
const fixture = TestBed.createComponent(AnimalListComponent);
const animalList = fixture.debugElement.componentInstance;
const animalList = fixture.componentInstance;

animalList.animalsName = 'Wallabies';
animalList.animalType = 'WALLABIES';
Expand Down
14 changes: 7 additions & 7 deletions packages/example-app/src/app/animals/animal-list/component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { Animal } from '../model';

@Component({
Expand All @@ -9,16 +9,16 @@ import { Animal } from '../model';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AnimalListComponent {
@Input() animalsName: string;
@Input() animalType: string;
@Input() animals: Observable<Animal[]>;
@Input() loading: Observable<boolean>;
@Input() error: Observable<any>;
@Input() animalsName!: string;
@Input() animalType!: string;
@Input() animals!: Observable<Animal[]>;
@Input() loading!: Observable<boolean>;
@Input() error!: Observable<any>;

// Since we're observing an array of items, we need to set up a 'trackBy'
// parameter so Angular doesn't tear down and rebuild the list's DOM every
// time there's an update.
getKey(_, animal: Animal) {
getKey(_: any, animal: Animal) {
return animal.id;
}
}
21 changes: 12 additions & 9 deletions packages/example-app/src/app/animals/animal/component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import {
MockNgRedux,
NgReduxTestingModule,
MockObservableStore,
} from '@angular-redux/store/testing';
import { async, TestBed } from '@angular/core/testing';
import 'rxjs/add/operator/toArray';
import { CoreModule } from '../../core/module';
import { AnimalComponent } from './component';
import { toArray } from 'rxjs/operators';
import { Reducer, AnyAction } from 'redux';

xdescribe('AnimalComponent', () => {
type ConfigureSubStoreFn = (basePath: (string | number)[], _: Reducer<any, AnyAction>) => MockObservableStore<any>

describe('AnimalComponent', () => {
let fixture;
let animalComponent;
let spyConfigureSubStore;
let animalComponent: AnimalComponent;
let spyConfigureSubStore: ConfigureSubStoreFn;

beforeEach(async(() => {
spyConfigureSubStore = spyOn(
MockNgRedux.mockInstance,
MockNgRedux.mockInstance!,
'configureSubStore',
).and.callThrough();

Expand All @@ -25,7 +29,7 @@ xdescribe('AnimalComponent', () => {
}).compileComponents();

fixture = TestBed.createComponent(AnimalComponent);
animalComponent = fixture.debugElement.componentInstance;
animalComponent = fixture.componentInstance;

animalComponent.key = 'id1';
animalComponent.animalType = 'WALLABIES';
Expand All @@ -36,7 +40,7 @@ xdescribe('AnimalComponent', () => {
it('should use the key to create a subStore', () =>
expect(spyConfigureSubStore).toHaveBeenCalledWith(
['WALLABIES', 'items', 'id1'],
jasmine.any(Function),
expect.any(Function)
));

it('select name data from the substore', async(() => {
Expand Down Expand Up @@ -98,8 +102,7 @@ xdescribe('AnimalComponent', () => {
quantityStub.next(5);
quantityStub.complete();

animalComponent.subTotal$
.toArray()
animalComponent.subTotal$.pipe(toArray())
.subscribe(subTotals => expect(subTotals).toEqual([5, 10, 15]));
}));
});
Loading