-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(docs-infra): draft to ensure that everything is setup properly t…
…o run tests against the Rx-JS examples Addresses #28017
- Loading branch information
1 parent
0213417
commit acf8db2
Showing
33 changed files
with
421 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"spec_dir": "content/examples", | ||
"spec_files": [ | ||
"observables/dist/out-tsc/src/**/*[sP]pec.js", | ||
"practical-observable-usage/dist/out-tsc/src/**/*[sP]pec.js", | ||
"rx-library/dist/out-tsc/content/examples/rx-library/src/**/*[sP]pec.js" | ||
|
||
], | ||
"stopSpecOnExpectationFailure": true, | ||
"random": false, | ||
"reporter": "jasmine-spec-reporter", | ||
"helpers": ["spec/helpers/reporter.js"] | ||
} |
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 { sequence } from './creating'; | ||
import { cold } from 'jasmine-marbles'; | ||
|
||
describe('observables', () => { | ||
it('should create an observable using the constructor', () => { | ||
const source = sequence; | ||
const expected = cold('(abc|)', { a: 1, b: 2, c: 3 }); | ||
expect(source).toBeObservable(expected); | ||
}); | ||
}); |
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,20 @@ | ||
import { sequence, multicastSequence } from './multicasting'; | ||
import { toArray } from 'rxjs/operators'; | ||
|
||
describe('sequence', () => { | ||
it('should create an observable and emit in sequence', (doneFn: DoneFn) => { | ||
sequence.pipe(toArray()).subscribe((output: Array<number>) => { | ||
expect(output).toEqual([1, 2, 3]); | ||
doneFn(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('multicast', () => { | ||
it('should create an observable and multicast the emissions', (doneFn: DoneFn) => { | ||
multicastSequence.pipe(toArray()).subscribe((output: Array<number>) => { | ||
expect(output).toEqual([1, 2, 3]); | ||
doneFn(); | ||
}); | ||
}); | ||
}); |
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,11 @@ | ||
import { myObservable } from './subscribing'; | ||
import { toArray } from 'rxjs/operators'; | ||
|
||
describe('subscribing', () => { | ||
it('should subscribe and emit', (doneFn: DoneFn) => { | ||
myObservable.pipe(toArray()).subscribe((output: Array<number>) => { | ||
expect(output).toEqual([1, 2, 3]); | ||
doneFn(); | ||
}); | ||
}); | ||
}); |
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
31 changes: 31 additions & 0 deletions
31
aio/content/examples/practical-observable-usage/src/backoff-spec.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,31 @@ | ||
import { backoff } from './backoff'; | ||
import { map } from 'rxjs/operators'; | ||
import { Subject } from 'rxjs'; | ||
|
||
describe('observables', () => { | ||
it('should retryWhen 3 times', (doneFn: DoneFn) => { | ||
const obs = new Subject(); | ||
obs | ||
.pipe( | ||
map(val => { | ||
if (val === 4) { | ||
throw val; | ||
} | ||
return val; | ||
}), | ||
backoff(3, 250) | ||
) | ||
.subscribe(a => { | ||
// should not emit 4 | ||
expect(a).not.toEqual(4); | ||
if (a === 3) { | ||
doneFn(); | ||
} | ||
}); | ||
|
||
obs.next(1); | ||
obs.next(2); | ||
obs.next(3); | ||
obs.next(4); | ||
}); | ||
}); |
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
20 changes: 20 additions & 0 deletions
20
aio/content/examples/practical-observable-usage/src/typeahead-spec.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,20 @@ | ||
import { document, typeahead } from './typeahead'; | ||
|
||
fdescribe('typeahead', () => { | ||
it('should listen to input changes', (doneFn: DoneFn) => { | ||
typeahead.subscribe((data) => { | ||
expect(data).toBe('Hello'); | ||
doneFn(); | ||
}); | ||
|
||
const input = document.getElementById('search-box'); | ||
const event = document.createEvent('Event'); | ||
input.value = 'Hello'; | ||
event.initEvent( | ||
'input', | ||
true, | ||
true | ||
); | ||
input.dispatchEvent(event); | ||
}); | ||
}); |
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
10 changes: 10 additions & 0 deletions
10
aio/content/examples/rx-library/src/error-handling-spec.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,10 @@ | ||
import { apiData } from './error-handling'; | ||
import { cold } from 'jasmine-marbles'; | ||
|
||
describe('error-handling', () => { | ||
it('should return an empty array', () => { | ||
const source = apiData; | ||
const expected = cold('(a|)', { a: [] }); | ||
expect(source).toBeObservable(expected); | ||
}); | ||
}); |
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,10 @@ | ||
import { squaredNums } from './operators'; | ||
import { cold } from 'jasmine-marbles'; | ||
|
||
describe('squaredNums - operators.ts', () => { | ||
it('should return square odds', () => { | ||
const source = squaredNums; | ||
const expected = cold('(abc|)', { a: 1, b: 4, c: 9 }); | ||
expect(source).toBeObservable(expected); | ||
}); | ||
}); |
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,10 @@ | ||
import { squareOdd } from './operators.1'; | ||
import { cold } from 'jasmine-marbles'; | ||
|
||
describe('squareOdd - operators.1.ts', () => { | ||
it('should return square odds', () => { | ||
const source = squareOdd; | ||
const expected = cold('(abc|)', { a: 1, b: 9, c: 25 }); | ||
expect(source).toBeObservable(expected); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -20,4 +20,4 @@ squareOdd.subscribe(x => console.log(x)); | |
|
||
// #enddocregion | ||
|
||
|
||
export { squareOdd }; |
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,10 @@ | ||
import { squareOdd } from './operators.2'; | ||
import { cold } from 'jasmine-marbles'; | ||
|
||
describe('squareOdd - operators.2.ts', () => { | ||
it('should return square odds', () => { | ||
const source = squareOdd; | ||
const expected = cold('(abc|)', { a: 1, b: 9, c: 25 }); | ||
expect(source).toBeObservable(expected); | ||
}); | ||
}); |
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.