-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61b5de8
commit 71a0f45
Showing
3 changed files
with
85 additions
and
1 deletion.
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,47 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should wrap in module 1`] = ` | ||
"declare module \\"myModule\\" { | ||
declare type Test = \\"ok\\" | \\"error\\"; | ||
declare type Test2 = \\"ok\\" | \\"error\\"; | ||
declare type Maybe<T> = | ||
| { | ||
type: \\"just\\", | ||
value: T, | ||
... | ||
} | ||
| { | ||
type: \\"nothing\\", | ||
... | ||
}; | ||
declare type Ref<T> = { | ||
current: T, | ||
... | ||
}; | ||
declare var ok: number; | ||
} | ||
" | ||
`; | ||
exports[`should wrap in module with scoped name 1`] = ` | ||
"declare module \\"@company/project\\" { | ||
declare type Test = \\"ok\\" | \\"error\\"; | ||
declare type Test2 = \\"ok\\" | \\"error\\"; | ||
declare type Maybe<T> = | ||
| { | ||
type: \\"just\\", | ||
value: T, | ||
... | ||
} | ||
| { | ||
type: \\"nothing\\", | ||
... | ||
}; | ||
declare type Ref<T> = { | ||
current: T, | ||
... | ||
}; | ||
declare var ok: number; | ||
} | ||
" | ||
`; |
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,30 @@ | ||
import { compiler, beautify } from ".."; | ||
import "../test-matchers"; | ||
|
||
it("should wrap in module", () => { | ||
const ts = ` | ||
declare export type Test = 'ok' | 'error' | ||
declare type Test2 = 'ok' | 'error' | ||
type Maybe<T> = {type: 'just', value: T} | {type: 'nothing'} | ||
export type Ref<T> = { current: T } | ||
export const ok: number | ||
`; | ||
const result = compiler.compileDefinitionString(ts, { quiet: true, asModule: "myModule" }); | ||
expect(beautify(result)).toMatchSnapshot(); | ||
expect(result).toBeValidFlowTypeDeclarations(); | ||
}); | ||
|
||
it("should wrap in module with scoped name", () => { | ||
const ts = ` | ||
declare export type Test = 'ok' | 'error' | ||
declare type Test2 = 'ok' | 'error' | ||
type Maybe<T> = {type: 'just', value: T} | {type: 'nothing'} | ||
export type Ref<T> = { current: T } | ||
export const ok: number | ||
`; | ||
const result = compiler.compileDefinitionString(ts, { quiet: true, asModule: "@company/project" }); | ||
expect(beautify(result)).toMatchSnapshot(); | ||
expect(result).toBeValidFlowTypeDeclarations(); | ||
}); |
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