|
1 | 1 | import {TypeSystem} from '..'; |
2 | | -import {TypeRouter} from '../TypeRouter'; |
3 | 2 |
|
4 | 3 | test('generates TypeScript source for simple string type', () => { |
5 | 4 | const system = new TypeSystem(); |
@@ -92,49 +91,3 @@ test('type interface inside a tuple', () => { |
92 | 91 | " |
93 | 92 | `); |
94 | 93 | }); |
95 | | - |
96 | | -test('can export whole router', () => { |
97 | | - const system = new TypeSystem(); |
98 | | - const {t} = system; |
99 | | - const router = new TypeRouter({system, routes: {}}).extend(() => ({ |
100 | | - callMe: t.Function(t.str, t.num), |
101 | | - 'block.subscribe': t.Function$(t.Object(t.prop('id', t.str)), t.obj), |
102 | | - })); |
103 | | - expect(router.toTypeScript()).toMatchInlineSnapshot(` |
104 | | - "export namespace Router { |
105 | | - export type Routes = { |
106 | | - callMe: (request: string) => Promise<number>; |
107 | | - "block.subscribe": (request$: Observable<{ |
108 | | - id: string; |
109 | | - }>) => Observable<{}>; |
110 | | - }; |
111 | | - } |
112 | | - " |
113 | | - `); |
114 | | -}); |
115 | | - |
116 | | -test('can export whole router and aliases', () => { |
117 | | - const system = new TypeSystem(); |
118 | | - const {t} = system; |
119 | | - system.alias('Document', t.Object(t.prop('id', t.str), t.prop('title', t.str)).options({title: 'The document'})); |
120 | | - const router = new TypeRouter({system, routes: {}}).extend(() => ({ |
121 | | - callMe: t.Function(t.str, t.num), |
122 | | - 'block.subscribe': t.Function$(t.Object(t.prop('id', t.str)), t.Ref('Document')), |
123 | | - })); |
124 | | - expect(router.toTypeScript()).toMatchInlineSnapshot(` |
125 | | - "export namespace Router { |
126 | | - export type Routes = { |
127 | | - callMe: (request: string) => Promise<number>; |
128 | | - "block.subscribe": (request$: Observable<{ |
129 | | - id: string; |
130 | | - }>) => Observable<Document>; |
131 | | - }; |
132 | | -
|
133 | | - export interface Document { |
134 | | - id: string; |
135 | | - title: string; |
136 | | - } |
137 | | - } |
138 | | - " |
139 | | - `); |
140 | | -}); |
0 commit comments