-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3953158
commit e29840e
Showing
18 changed files
with
293 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts"], | ||
"extends": [ | ||
"plugin:@nx/angular", | ||
"plugin:@angular-eslint/template/process-inline-templates" | ||
], | ||
"rules": { | ||
"@angular-eslint/directive-selector": [ | ||
"error", | ||
{ | ||
"type": "attribute", | ||
"prefix": "lib", | ||
"style": "camelCase" | ||
} | ||
], | ||
"@angular-eslint/component-selector": [ | ||
"error", | ||
{ | ||
"type": "element", | ||
"prefix": "lib", | ||
"style": "kebab-case" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"files": ["*.html"], | ||
"extends": ["plugin:@nx/angular-template"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# disney-planner-trips-ngrx | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test disney-planner-trips-ngrx` to execute the unit tests. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'disney-planner-trips-ngrx', | ||
preset: '../../jest.preset.js', | ||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'], | ||
coverageDirectory: '../../coverage/libs/disney-planner-trips-ngrx', | ||
transform: { | ||
'^.+\\.(ts|mjs|js|html)$': [ | ||
'jest-preset-angular', | ||
{ | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
stringifyContentPathRegex: '\\.(html|svg)$', | ||
}, | ||
], | ||
}, | ||
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], | ||
snapshotSerializers: [ | ||
'jest-preset-angular/build/serializers/no-ng-attributes', | ||
'jest-preset-angular/build/serializers/ng-snapshot', | ||
'jest-preset-angular/build/serializers/html-comment', | ||
], | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "disney-planner-trips-ngrx", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/disney-planner-trips-ngrx/src", | ||
"prefix": "lib", | ||
"tags": [], | ||
"projectType": "library", | ||
"targets": { | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "libs/disney-planner-trips-ngrx/jest.config.ts" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": [ | ||
"libs/disney-planner-trips-ngrx/**/*.ts", | ||
"libs/disney-planner-trips-ngrx/**/*.html" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * as fromUpcomingTripsActions from './lib/disney-planner-trips-ngrx/trips.actions'; | ||
export * as fromUpcomingTrips from './lib/disney-planner-trips-ngrx/trips.feature'; | ||
export * as fromUpcomingTripsSelectors from './lib/disney-planner-trips-ngrx/trips.selectors'; | ||
export * as fromUpcomingTripsEffects from './lib/disney-planner-trips-ngrx/trips.effects'; |
6 changes: 6 additions & 0 deletions
6
libs/disney-planner-trips-ngrx/src/lib/disney-planner-trips-ngrx/trips.actions.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createAction } from '@ngrx/store'; | ||
import { UpcomingTrip } from 'disney-planner-models'; | ||
|
||
export const loadUpcomingTrips = createAction('[UpcomingTrips] Load UpcomingTrips'); | ||
export const loadUpcomingTripsSuccess = createAction('[UpcomingTrips] Load UpcomingTrips Success', (trips: UpcomingTrip[]) => ({ trips })); | ||
export const loadUpcomingTripsFailure = createAction('[UpcomingTrips] Load UpcomingTrips Failure'); |
39 changes: 39 additions & 0 deletions
39
libs/disney-planner-trips-ngrx/src/lib/disney-planner-trips-ngrx/trips.effects.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Injectable, inject } from '@angular/core'; | ||
import { Actions, createEffect, ofType } from '@ngrx/effects'; | ||
import { loadUpcomingTrips, loadUpcomingTripsSuccess } from './trips.actions'; | ||
import { filter, switchMap, withLatestFrom } from 'rxjs'; | ||
import { Store } from '@ngrx/store'; | ||
import { selectUpcomingTrips } from './trips.selectors'; | ||
import { UpcomingTrip } from 'disney-planner-models'; | ||
|
||
@Injectable() | ||
export class UpcomingTripsEffects { | ||
private _actions$ = inject(Actions); | ||
private _store = inject(Store); | ||
|
||
loadUpcomingTrips$ = createEffect( | ||
() => this._actions$.pipe( | ||
ofType(loadUpcomingTrips), | ||
withLatestFrom(this._store.select(selectUpcomingTrips)), | ||
filter(([, trips]) => !trips.length), | ||
switchMap(() => { | ||
const mockTrips: UpcomingTrip[] = [ | ||
{ | ||
date: '2023-12-15', | ||
park: 'magic' | ||
}, | ||
{ | ||
date: '2023-12-16', | ||
park: 'epcot' | ||
}, | ||
{ | ||
date: '2023-12-17', | ||
park: 'studios' | ||
} | ||
]; | ||
return [loadUpcomingTripsSuccess(mockTrips)]; | ||
}) | ||
|
||
) | ||
); | ||
} |
24 changes: 24 additions & 0 deletions
24
libs/disney-planner-trips-ngrx/src/lib/disney-planner-trips-ngrx/trips.feature.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createFeature, createReducer, on } from '@ngrx/store'; | ||
import { UpcomingTrip } from 'disney-planner-models'; | ||
import { loadUpcomingTripsSuccess } from './trips.actions'; | ||
|
||
export interface UpcomingTripsState { | ||
readonly trips: UpcomingTrip[]; | ||
} | ||
|
||
const initialState: UpcomingTripsState = { | ||
trips: [] | ||
}; | ||
|
||
export const TRIPS_STATE_KEY = 'upcomingTrips'; | ||
|
||
export const upcomingTripsFeature = createFeature({ | ||
name: TRIPS_STATE_KEY, | ||
reducer: createReducer( | ||
initialState, | ||
on( | ||
loadUpcomingTripsSuccess, | ||
(state, { trips }) => ({ ...state, trips }) | ||
) | ||
) | ||
}); |
11 changes: 11 additions & 0 deletions
11
libs/disney-planner-trips-ngrx/src/lib/disney-planner-trips-ngrx/trips.selectors.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createFeatureSelector, createSelector } from '@ngrx/store'; | ||
import { TRIPS_STATE_KEY, UpcomingTripsState } from './trips.feature'; | ||
import { | ||
} from './trips.feature'; | ||
|
||
export const selectUpcomingTripsState = createFeatureSelector<UpcomingTripsState>(TRIPS_STATE_KEY); | ||
|
||
export const selectUpcomingTrips = createSelector( | ||
selectUpcomingTripsState, | ||
(state: UpcomingTripsState) => state.trips | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment | ||
globalThis.ngJest = { | ||
testEnvironmentOptions: { | ||
errorOnUnknownElements: true, | ||
errorOnUnknownProperties: true, | ||
}, | ||
}; | ||
import 'jest-preset-angular/setup-jest'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2022", | ||
"useDefineForClassFields": false, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
], | ||
"extends": "../../tsconfig.base.json", | ||
"angularCompilerOptions": { | ||
"enableI18nLegacyMessageIdFormat": false, | ||
"strictInjectionParameters": true, | ||
"strictInputAccessModifiers": true, | ||
"strictTemplates": true | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"declaration": true, | ||
"declarationMap": true, | ||
"inlineSources": true, | ||
"types": [] | ||
}, | ||
"exclude": [ | ||
"src/**/*.spec.ts", | ||
"src/test-setup.ts", | ||
"jest.config.ts", | ||
"src/**/*.test.ts" | ||
], | ||
"include": ["src/**/*.ts"] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"target": "es2016", | ||
"types": ["jest", "node"] | ||
}, | ||
"files": ["src/test-setup.ts"], | ||
"include": [ | ||
"jest.config.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.d.ts" | ||
] | ||
} |
This file contains 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