-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from kwonoj/feat-export-type
feat(index): export types for functions
- Loading branch information
Showing
7 changed files
with
182 additions
and
133 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
import { SubscriptionLog } from 'rxjs/testing/SubscriptionLog'; | ||
import { TestMessage } from './message/TestMessage'; | ||
import { RxSandboxInstance } from './RxSandboxInstance'; | ||
|
||
export interface RxSandbox { | ||
/** | ||
* Creates new instance of test scheduler for testing observables. | ||
* | ||
* @param {boolean} [autoFlush] Flush scheduler automatically when `getMarbles` is being called. False by default. | ||
* @param {number} [frameTimeFactor] Custom frametime factor for virtual time frame. 1 by default. | ||
* @param {number} [maxFrameValue] Maximum frame value of marble diagram can be read. | ||
* If marble has value over max frame, it'll be ignored when scheduler flushes out. | ||
* 1000 * frameTimeFactory by default. | ||
* @return {RxSandboxInstance} instance of test scheduler interfaces. | ||
*/ | ||
create(autoFlush?: boolean, frameTimeFactor?: number, maxFrameValue?: number): RxSandboxInstance; | ||
/** | ||
* Utility assertion method to assert marble based observable test messages. | ||
* By default return values of sandbox functions are plain object works with | ||
* any testing framework or assertion library, while this assertion provides | ||
* better visualization against observable test messages. | ||
* | ||
*/ | ||
marbleAssert<T = string>( | ||
source: Array<TestMessage<T | Array<TestMessage<T>>>> | Readonly<Array<TestMessage<T | Array<TestMessage<T>>>>> | ||
): { | ||
to: { | ||
equal( | ||
expected: | ||
| Array<TestMessage<T | Array<TestMessage<T>>>> | ||
| Readonly<Array<TestMessage<T | Array<TestMessage<T>>>>> | ||
): void; | ||
}; | ||
}; | ||
marbleAssert(source: Array<SubscriptionLog>): { to: { equal(expected: Array<SubscriptionLog>): void } }; | ||
} |
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,59 @@ | ||
import { SubscriptionLog } from 'rxjs/testing/SubscriptionLog'; | ||
import { TestMessage } from './message/TestMessage'; | ||
import { TestScheduler } from './scheduler/TestScheduler'; | ||
|
||
type hotObservable = typeof TestScheduler.prototype.createHotObservable; | ||
type coldObservable = typeof TestScheduler.prototype.createColdObservable; | ||
type flushScheduler = typeof TestScheduler.prototype.flush; | ||
type advanceToScheduler = typeof TestScheduler.prototype.advanceTo; | ||
type getObservableMessage = typeof TestScheduler.prototype.getMessages; | ||
type expectedObservable = <T = string>( | ||
marble: string, | ||
value?: { [key: string]: T } | null, | ||
error?: any | ||
) => Readonly<Array<TestMessage<T | Array<TestMessage<T>>>>>; | ||
type expectedSubscription = (marble: string) => SubscriptionLog; | ||
|
||
type RxSandboxInstance = { | ||
/** | ||
* Creates a hot observable using marble diagram DSL, or TestMessage. | ||
*/ | ||
hot: hotObservable; | ||
/** | ||
* Creates a cold obsrevable using marbld diagram DSL, or TestMessage. | ||
*/ | ||
cold: coldObservable; | ||
/** | ||
* Flush out currently scheduled observables, fill values returned by `getMarbles`. | ||
*/ | ||
flush: flushScheduler; | ||
/** | ||
* Flush out currently scheduled observables, only until reaches frame specfied. | ||
*/ | ||
advanceTo: advanceToScheduler; | ||
/** | ||
* Get array of observable value's metadata TestMessage<T> from observable | ||
* created via `hot` or `cold`. Returned array will be filled once scheduler flushes | ||
* scheduled actions, either via explicit `flush` or implicit `autoFlush`. | ||
*/ | ||
getMessages: getObservableMessage; | ||
/** | ||
* Utility function to generate `expected` values via marble diagram. | ||
*/ | ||
e: expectedObservable; | ||
/** | ||
* Utility function to generate `expected` subscriptions via marble diagram. | ||
*/ | ||
s: expectedSubscription; | ||
}; | ||
|
||
export { | ||
hotObservable, | ||
coldObservable, | ||
flushScheduler, | ||
advanceToScheduler, | ||
getObservableMessage, | ||
expectedObservable, | ||
expectedSubscription, | ||
RxSandboxInstance | ||
}; |
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