-
Notifications
You must be signed in to change notification settings - Fork 73
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 #47 from marblejs/feature/combineRoutesMiddleware
feat(core): use middlewares with `combinedRoutes`
- Loading branch information
Showing
5 changed files
with
146 additions
and
21 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
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,21 +1,55 @@ | ||
import { mapTo } from 'rxjs/operators'; | ||
import { isEffect, isGroup } from './effects.helpers'; | ||
import { Effect, GroupedEffects } from './effects.interface'; | ||
import { isEffect, isGroup, isRouteCombinerConfig, isRouteCombinerEffects } from './effects.helpers'; | ||
import { Effect, GroupedEffects, RouteCombinerConfig } from './effects.interface'; | ||
|
||
describe('Effects helpers', () => { | ||
|
||
it('#isGroup checks if parameters is GroupedEffects type', () => { | ||
expect(isGroup({ path: '/test', effects: [] })).toBe(true); | ||
expect(isGroup({ path: '/test', effects: {} } as GroupedEffects)).toBe(false); | ||
test('#isGroup checks if parameters is GroupedEffects type', () => { | ||
expect(isGroup({ path: '/test', effects: [] } as GroupedEffects)).toBe(true); | ||
expect(isGroup({ path: '/test', effects: {} } as GroupedEffects)).toBe(false); | ||
expect(isGroup({ effects: [] } as any as GroupedEffects)).toBe(false); | ||
}); | ||
|
||
it('#isEffect checks if parameters is GroupedEffects type', () => { | ||
test('#isEffect checks if parameters is GroupedEffects type', () => { | ||
// given | ||
const effect$: Effect = request$ => request$.pipe(mapTo({})); | ||
const groupedEffects = { path: '/test', effects: [effect$] }; | ||
const groupedEffects = { path: '/test', effects: [effect$], middlewares: [] }; | ||
|
||
// when | ||
const effect = isEffect(effect$); | ||
const group = isEffect(groupedEffects); | ||
|
||
// then | ||
expect(effect).toBe(true); | ||
expect(group).toBe(false); | ||
}); | ||
|
||
test('#isRouteCombinerConfig checks if parameter is a configuration object', () => { | ||
// given | ||
const effects = []; | ||
const combinedRoutes: RouteCombinerConfig = { middlewares: [], effects: [] }; | ||
|
||
// when | ||
const combinedRoutesEffects = isRouteCombinerConfig(effects); | ||
const combinedRoutesConfig = isRouteCombinerConfig(combinedRoutes); | ||
|
||
expect(isEffect(effect$)).toBe(true); | ||
expect(isEffect(groupedEffects)).toBe(false); | ||
// then | ||
expect(combinedRoutesConfig).toBe(true); | ||
expect(combinedRoutesEffects).toBe(false); | ||
}); | ||
|
||
test('#isRouteCombinerEffects checks if parameters is a collection of effects', () => { | ||
// given | ||
const effects = []; | ||
const combinedRoutes: RouteCombinerConfig = { middlewares: [], effects: [] }; | ||
|
||
// when | ||
const combinedRoutesEffects = isRouteCombinerEffects(effects); | ||
const combinedRoutesConfig = isRouteCombinerEffects(combinedRoutes); | ||
|
||
// then | ||
expect(combinedRoutesConfig).toBe(false); | ||
expect(combinedRoutesEffects).toBe(true); | ||
}); | ||
|
||
}); |
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