Skip to content

Commit

Permalink
Merge branch 'part-24' of https://github.com/anihalaney/rwa-trivia in…
Browse files Browse the repository at this point in the history
…to BW-202
  • Loading branch information
yugank1991 committed Sep 11, 2018
2 parents 76b46b0 + 2bf249c commit 18f19fa
Show file tree
Hide file tree
Showing 19 changed files with 554 additions and 29 deletions.
4 changes: 3 additions & 1 deletion functions/utils/ESUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ export class ESUtils {
return prefix + index;
}

static createOrUpdateIndex(index: string, type: string, data: any, key: string): Promise<any> {
static createOrUpdateIndex(index: string, type: string, data: Question, key: string): Promise<any> {
const client: Elasticsearch.Client = this.getElasticSearchClient();
index = this.getIndex(index);

data.createdOn = new Date(data.createdOn['_seconds'] * 1000);

return client.index({
index: index,
type: type,
Expand Down
30 changes: 24 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,16 @@
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "6.0.6",
"@angular-devkit/build-ng-packagr": "~0.6.8",
"@angular-devkit/build-angular": "~0.6.8",
"ng-packagr": "^3.0.0-rc.2",
"tsickle": ">=0.25.5",
"tslib": "^1.7.1",
"typescript": "2.7.2",
"@angular-devkit/build-ng-packagr": "~0.6.8",
"@angular/cli": "6.0.8",
"@angular/compiler-cli": "6.0.6",
"@types/hammerjs": "2.0.35",
"@types/jasmine": "2.8.8",
"@types/jest": "^23.1.4",
"@types/node": "10.3.5",
"codelyzer": "4.4.1",
"husky": "^1.0.0-rc.13",
"jasmine-core": "3.1.0",
"jasmine-spec-reporter": "4.2.1",
"jest": "^23.3.0",
Expand All @@ -114,12 +111,33 @@
"karma-coverage-istanbul-reporter": "2.0.1",
"karma-jasmine": "1.1.2",
"karma-jasmine-html-reporter": "1.1.0",
"ng-packagr": "^3.0.0-rc.2",
"protractor": "5.3.0",
"source-map-explorer": "1.5.0",
"ts-loader": "^4.2.0",
"ts-node": "7.0.0",
"tsickle": ">=0.25.5",
"tslib": "^1.7.1",
"tslint": "5.10.0",
"typescript": "2.7.2",
"webpack-cli": "^3.0.8",
"xmlhttprequest": "^1.8.0"
},
"jest": {
"preset": "jest-preset-angular",
"setupTestFrameworkScriptFile": "<rootDir>/projects/trivia/src/setup-jest.ts",
"verbose": true,
"testURL": "http://localhost/",
"globals": {
"ts-jest": {
"tsConfigFile": "projects/trivia/tsconfig.spec.json"
},
"__TRANSFORM_HTML__": true
}
},
"husky": {
"hooks": {
"pre-push": "npm run test && ng e2e trivia-e2e"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { QuestionService } from '../../../core/services/question.service';
import { QuestionActions } from '../actions';
import { RouterNavigationPayload, RouterNavigationAction, ROUTER_NAVIGATION } from '@ngrx/router-store';
import { RoutesRecognized } from '@angular/router';
import { Question, RouterStateUrl } from '../../../model';
import { Question, RouterStateUrl } from '../../../shared/model';


describe('Effects: QuestionEffects', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Observable } from 'rxjs';
import { Action } from '@ngrx/store';
import { QuestionActions } from '../actions';
import { Question, SearchResults } from '../../../model';
import { Question, SearchResults } from '../../../../../../shared-library/src/lib/shared/model';
import { questionOfTheDay } from './questions.reducer';
import { TEST_DATA } from '../../../testing/test.data';

Expand Down
4 changes: 4 additions & 0 deletions projects/shared-library/src/lib/testing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './router-stubs';
export * from './mock-store';
export * from './mock-auth.service';
export * from './test.data';
6 changes: 6 additions & 0 deletions projects/shared-library/src/lib/testing/mock-auth.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class MockAuthService {

ensureLogin = (url?: string) => {};
logout = () => {}

}
20 changes: 20 additions & 0 deletions projects/shared-library/src/lib/testing/mock-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Action } from '@ngrx/store';

import { Observable } from 'rxjs';
import { BehaviorSubject } from 'rxjs';
import { map } from 'rxjs/operators';

export class MockStore<T> extends BehaviorSubject<T> {

constructor(private _initialState: T) {
super(_initialState);
}

dispatch = (action: Action): void => {
}

select = <T, R>(pathOrMapFn: any, ...paths: string[]): Observable<R> => {
return map.call(this, pathOrMapFn);
}

}
31 changes: 31 additions & 0 deletions projects/shared-library/src/lib/testing/router-stubs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Component, Directive, Input, Injectable } from '@angular/core';
import { NavigationExtras } from '@angular/router';

@Directive({
selector: '[routerLink]',
host: {
'(click)': 'onClick()'
}
})
export class RouterLinkStubDirective {
@Input('routerLink') linkParams: any;
navigatedTo: any = null;

onClick() {
this.navigatedTo = this.linkParams;
}
}

@Component({
selector: 'router-outlet',
template: ''
})
export class RouterOutletStubComponent {

}

@Injectable()
export class RouterStub {
navigate(commands: any[], extras?: NavigationExtras) { }
}

Loading

0 comments on commit 18f19fa

Please sign in to comment.