This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as Actions from './data.actions'; | |
| export interface State { | |
| data: any; | |
| } | |
| export const initialState: State = { | |
| data: null | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as Actions from './data.actions'; | |
| describe('Store > Data > DataActions', () => { | |
| it('SHOULD create a LoadData action', () => { | |
| const action = new Actions.LoadData(); | |
| expect(action.type).toEqual(Actions.LOAD_DATA); | |
| }); | |
| it('SHOULD create a SetData action containing a payload', () => { | |
| const payload = { id: 1, value: {} }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable, of } from 'rxjs'; | |
| import { Action } from '@ngrx/store'; | |
| import { TestBed, async } from '@angular/core/testing'; | |
| import { provideMockActions } from '@ngrx/effects/testing'; | |
| import { provideMockStore } from '@ngrx/store/testing'; | |
| import { DataEffect } from './data.effects'; | |
| import * as fromActions from './data.actions'; | |
| import { DataService } from '@app/data/services/data/data.service'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as fromReducer from './data.reducer'; | |
| import * as fromActions from './data.actions'; | |
| describe('Store > Data > DataReducer', () => { | |
| afterEach(() => { | |
| fromReducer.initialState.data = null; | |
| }); | |
| it('SHOULD return the default state', () => { | |
| const { initialState } = fromReducer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createSelector } from '@ngrx/store'; | |
| import { AppState } from '@store/app.reducer'; | |
| const dataFeature = (state: AppState) => state.data; | |
| export const getData = createSelector( | |
| dataFeature, | |
| state => state.data | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as selectors from './data.selectors'; | |
| import { AppState } from '@store/app.reducer'; | |
| import { State } from './data.reducer'; | |
| const createData = ({ | |
| name = '', | |
| value = null | |
| } = {}): any => ({ | |
| name, value | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Commented configuration | |
| // import { MockStore, provideMockStore } from '@ngrx/store/testing'; | |
| // let store: MockStore<any>; | |
| // beforeEach(async(() => { | |
| // TestBed.configureTestingModule({ | |
| // [...] | |
| // providers: [ | |
| // provideMockStore({ initialState }), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| [...] | |
| "projects": { | |
| "my-project": { | |
| "architect": { | |
| "build": { | |
| "configurations": { | |
| "production": { | |
| "fileReplacements": [ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const environment = { | |
| production: true, | |
| apiUrl: '%#$WS_ROOT_URL#%' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "start:dev": "npm run generate-env-file:dev && ng serve --configuration=local-dev", | |
| "start:staging": "npm run generate-env-file:staging && ng serve --configuration=local-staging", | |
| "start:prod": "npm run generate-env-file:prod && ng serve --configuration=local-production", | |
| "generate-env-file:dev": "node .\\path\\to\\script\\replace-env-var.script.js dev", | |
| "generate-env-file:staging": "node .\\path\\to\\script\\replace-env-var.script.js staging", | |
| "generate-env-file:prod": "node .\\path\\to\\script\\replace-env-var.script.js prod", | |
| } |