-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: use StackBlitz WebContainers for live examples (#3321)
Closes #3261
- Loading branch information
1 parent
15d34af
commit 25cfd24
Showing
17 changed files
with
1,799 additions
and
5,817 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
17 changes: 6 additions & 11 deletions
17
projects/ngrx.io/content/examples/testing-store/src/app/state/books.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 |
---|---|---|
@@ -1,20 +1,15 @@ | ||
import { createSelector, createFeatureSelector } from "@ngrx/store"; | ||
import { AppState } from "./app.state"; | ||
import { Book } from "../book-list/books.model"; | ||
import { createSelector, createFeatureSelector } from '@ngrx/store'; | ||
import { Book } from '../book-list/books.model'; | ||
|
||
export const selectBooks = createSelector( | ||
(state: AppState) => state.books, | ||
(books: Array<Book>) => books | ||
); | ||
export const selectBooks = createFeatureSelector<ReadonlyArray<Book>>('books'); | ||
|
||
export const selectCollectionState = createFeatureSelector< | ||
ReadonlyArray<string> | ||
>("collection"); | ||
export const selectCollectionState = | ||
createFeatureSelector<ReadonlyArray<string>>('collection'); | ||
|
||
export const selectBookCollection = createSelector( | ||
selectBooks, | ||
selectCollectionState, | ||
(books: Array<Book>, collection: Array<string>) => { | ||
(books, collection) => { | ||
return collection.map((id) => books.find((book) => book.id === id)); | ||
} | ||
); |
2 changes: 0 additions & 2 deletions
2
projects/ngrx.io/content/examples/testing-store/src/global-jasmine.ts
This file was deleted.
Oops, something went wrong.
13 changes: 9 additions & 4 deletions
13
projects/ngrx.io/content/examples/testing-store/src/index.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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
<html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Angular App</title> | ||
<meta charset="utf-8" /> | ||
<title>NgRx Tutorial</title> | ||
<base href="/" /> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
</head> | ||
<body> | ||
<!-- Intentionally empty --> | ||
<app-root></app-root> | ||
</body> | ||
</html> | ||
</html> |
51 changes: 9 additions & 42 deletions
51
projects/ngrx.io/content/examples/testing-store/src/main.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 |
---|---|---|
@@ -1,45 +1,12 @@ | ||
import './global-jasmine'; | ||
import 'jasmine-core/lib/jasmine-core/jasmine-html.js'; | ||
import 'jasmine-core/lib/jasmine-core/boot.js'; | ||
// main app entry point | ||
import { enableProdMode } from '@angular/core'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
|
||
import './polyfills'; | ||
import { AppModule } from './app/app.module'; | ||
import { environment } from './environments/environment'; | ||
|
||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files | ||
import 'zone.js/dist/async-test'; | ||
import 'zone.js/dist/fake-async-test'; | ||
import 'zone.js/dist/long-stack-trace-zone'; | ||
import 'zone.js/dist/proxy.js'; | ||
import 'zone.js/dist/sync-test'; | ||
|
||
// Requires 'zone.js/dist/proxy.js' and 'zone.js/dist/sync-test'; | ||
import 'zone.js/dist/jasmine-patch'; | ||
|
||
import { getTestBed } from '@angular/core/testing'; | ||
import { | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting, | ||
} from '@angular/platform-browser-dynamic/testing'; | ||
|
||
import './app/state/books.reducer.spec.ts'; | ||
import './app/state/collection.reducer.spec.ts'; | ||
import './app/state/books.selectors.spec.ts'; | ||
import './app/app.component.spec.ts'; | ||
import './app/integration.spec.ts'; | ||
|
||
jasmine.getEnv().configure({ random: false }); | ||
bootstrap(); | ||
|
||
function bootstrap() { | ||
if (window.jasmineRef) { | ||
location.reload(); | ||
return; | ||
} else { | ||
window.onload(); | ||
window.jasmineRef = jasmine.getEnv(); | ||
} | ||
|
||
getTestBed().initTestEnvironment( | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting() | ||
); | ||
if (environment.production) { | ||
enableProdMode(); | ||
} | ||
|
||
platformBrowserDynamic().bootstrapModule(AppModule); |
2 changes: 0 additions & 2 deletions
2
projects/ngrx.io/content/examples/testing-store/src/test-files.ts
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
projects/ngrx.io/content/examples/testing-store/src/testing/global-jasmine.ts
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
projects/ngrx.io/content/examples/testing-store/stackblitz.json
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"description": "Store Testing Tutorial", | ||
"files": ["!**/*.d.ts", "!**/*.js", "**/*.spec.ts"] | ||
"files": ["!**/*.d.ts", "**/*.spec.ts"], | ||
"type": "testing" | ||
} |
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
Oops, something went wrong.