Skip to content

Commit 7b7096b

Browse files
committed
test(routerify): Convert xstream tests
1 parent 2a5b3eb commit 7b7096b

File tree

3 files changed

+237
-189
lines changed

3 files changed

+237
-189
lines changed

src/routerify.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ export declare type RouterSink = Stream<HistoryAction>;
1616
* @return {main} The augmented main function
1717
*/
1818
function routerify(main: (a: any) => any, routeMatcher: RouteMatcher, basename = '/', historyName = 'history', routerName = 'router') {
19+
if (typeof main !== 'function') {
20+
throw new Error('First argument to routerify must be a valid cycle app');
21+
}
1922
const createHref = (location: Location) => basename + createPath(location);
2023
return function(sources: any): any {
2124
const routerSource = new RouterSource(sources[historyName], [], createHref, routeMatcher);
2225
const sinks = main({ ...sources, [routerName]: routerSource });
2326
return {
2427
...sinks,
2528
[historyName]: adapt(xs.merge(
26-
xs.fromObservable(sinks[historyName]),
27-
xs.fromObservable(sinks[routerName])
29+
sinks[historyName] ? xs.fromObservable(sinks[historyName]) : xs.never(),
30+
sinks[routerName] ? xs.fromObservable(sinks[routerName]) : xs.never()
2831
))
2932
};
3033
};

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import './rxjs';
1+
//import './rxjs';
22
import './xstream';

0 commit comments

Comments
 (0)