-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fakeSchedulers): Add general implementation.
- Loading branch information
Showing
27 changed files
with
405 additions
and
71 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
Empty file.
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,9 @@ | ||
To run the tests in the Jasmine example: | ||
|
||
1. Install the Jasmine and the other dependencies using: | ||
|
||
`npm install` | ||
|
||
2. Run the tests using: | ||
|
||
`npm run test` |
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,37 @@ | ||
// These zone.js imports are only required because this is a stand-alone | ||
// example. When using fakeSchedulers in an Angular project, these zone.js | ||
// imports will be elsewhere. | ||
|
||
import "zone.js"; | ||
import "zone.js/dist/long-stack-trace-zone"; | ||
import "zone.js/dist/proxy.js"; | ||
import "zone.js/dist/sync-test"; | ||
import "zone.js/dist/jasmine-patch"; | ||
import "zone.js/dist/async-test"; | ||
import "zone.js/dist/fake-async-test"; | ||
|
||
import { tick } from "@angular/core/testing"; | ||
import { fakeSchedulers } from "rxjs-marbles/jasmine/angular"; | ||
import { of, timer } from "rxjs"; | ||
import { delay, map, tap } from "rxjs/operators"; | ||
|
||
describe("fakeSchedulers", () => { | ||
|
||
it("should support a timer", fakeSchedulers(() => { | ||
let received: number | undefined; | ||
timer(100).subscribe(value => received = value); | ||
tick(50); | ||
expect(received).not.toBeDefined(); | ||
tick(50); | ||
expect(received).toBe(0); | ||
})); | ||
|
||
it("should support delay", fakeSchedulers(() => { | ||
let received: number | undefined; | ||
of(1).pipe(delay(100)).subscribe(value => received = value); | ||
tick(50); | ||
expect(received).not.toBeDefined(); | ||
tick(50); | ||
expect(received).toBe(1); | ||
})); | ||
}); |
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 @@ | ||
{ | ||
"devDependencies": { | ||
"@angular/core": "^6.0.4", | ||
"@types/jasmine": "^2.5.53", | ||
"jasmine": "^3.0.0", | ||
"rxjs": "^6.0.0", | ||
"rxjs-marbles": "^4.2.0", | ||
"ts-node": "^6.0.0", | ||
"typescript": "^2.8.3", | ||
"zone.js": "~0.8.26" | ||
}, | ||
"name": "rxjs-marbles-examples-jasmine-angular", | ||
"scripts": { | ||
"test": "ts-node node_modules/jasmine/bin/jasmine *-spec.ts" | ||
}, | ||
"version": "0.0.0" | ||
} |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": false, | ||
"lib": ["es2015"], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noImplicitAny": true, | ||
"outDir": "build", | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"target": "es2015" | ||
}, | ||
"exclude": [], | ||
"include": ["*.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
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
Empty file.
Empty file.
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,47 @@ | ||
/** | ||
* @license Use of this source code is governed by an MIT-style license that | ||
* can be found in the LICENSE file at https://github.com/cartant/rxjs-marbles | ||
*/ | ||
/*tslint:disable:object-literal-sort-keys*/ | ||
|
||
import "zone.js"; | ||
import "zone.js/dist/long-stack-trace-zone"; | ||
import "zone.js/dist/proxy.js"; | ||
import "zone.js/dist/sync-test"; | ||
import "zone.js/dist/jasmine-patch"; | ||
import "zone.js/dist/async-test"; | ||
import "zone.js/dist/fake-async-test"; | ||
|
||
import { tick } from "@angular/core/testing"; | ||
import { asapScheduler, of, timer } from "rxjs"; | ||
import { delay, map, tap } from "rxjs/operators"; | ||
import { fakeSchedulers } from "../../dist/jasmine/angular"; | ||
|
||
describe("fakeSchedulers", () => { | ||
|
||
it("should support a timer", fakeSchedulers(() => { | ||
let received: number | undefined; | ||
timer(100).subscribe(value => received = value); | ||
tick(50); | ||
expect(received).not.toBeDefined(); | ||
tick(50); | ||
expect(received).toBe(0); | ||
})); | ||
|
||
it("should support delay", fakeSchedulers(() => { | ||
let received: number | undefined; | ||
of(1).pipe(delay(100)).subscribe(value => received = value); | ||
tick(50); | ||
expect(received).not.toBeDefined(); | ||
tick(50); | ||
expect(received).toBe(1); | ||
})); | ||
|
||
it("should support the asapScheduler", fakeSchedulers(() => { | ||
let received: number | undefined; | ||
of(1).pipe(delay(0, asapScheduler)).subscribe(value => received = value); | ||
expect(received).not.toBeDefined(); | ||
tick(0); | ||
expect(received).toBe(1); | ||
})); | ||
}); |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": ["jasmine", "node"] | ||
}, | ||
"extends": "../tsconfig.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
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.