-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(import): add import equals support and make sure transformer tes…
…t run in a context so the cache system will work * move import test into his own folder and remove unnecessary wording in readme for slack link * add import alias tests * add import equals support * remove duplicated test * rename import changed by mistake in previous commit * make sure transformer test run with a context so the cache feature can be tested
- Loading branch information
Showing
16 changed files
with
120 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const karmaBaseConfig = require('./karma.config.base'); | ||
|
||
module.exports = function(config) { | ||
const karmaConfig = karmaBaseConfig(config, '../../test/transformer/**/*.test.ts'); | ||
const karmaConfig = karmaBaseConfig(config, '../../test/transformer/context.ts'); | ||
|
||
config.set(karmaConfig); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,9 @@ | ||
import * as ts from 'typescript'; | ||
import { Scope } from '../../scope/scope'; | ||
import { GetDescriptor } from '../descriptor'; | ||
import { TypescriptHelper } from '../helper/helper'; | ||
|
||
export function GetImportEqualsDescriptor(node: ts.ImportEqualsDeclaration, scope: Scope): ts.Expression { | ||
const declaration: ts.Declaration = TypescriptHelper.GetDeclarationFromNode(node.moduleReference); | ||
return GetDescriptor(declaration, scope); | ||
} |
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,2 @@ | ||
const frameworkContext: __WebpackModuleApi.RequireContext = require.context('./', true, /\.test\.ts$/); | ||
frameworkContext.keys().map(frameworkContext); |
41 changes: 0 additions & 41 deletions
41
test/transformer/descriptor/create-mock-list-values.test.ts
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
test/transformer/descriptor/import.test.ts → ...nsformer/descriptor/import/import.test.ts
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,17 @@ | ||
import { createMock } from 'ts-auto-mock'; | ||
import { Interface as InterfaceAlias } from '../utils/interfaces/basic'; | ||
import { InterfaceAliasExport } from '../utils/interfaces/importAndExport'; | ||
|
||
describe('importAlias', () => { | ||
it('should use the correct import for an alias', () => { | ||
const mock: InterfaceAlias = createMock<InterfaceAlias>(); | ||
expect(mock.a).toBe(''); | ||
expect(mock.b).toBe(0); | ||
}); | ||
|
||
it('should use the correct import for an internal alias', () => { | ||
const mock: InterfaceAliasExport = createMock<InterfaceAliasExport>(); | ||
expect(mock.a).toBe(''); | ||
expect(mock.b).toBe(0); | ||
}); | ||
}); |
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,25 @@ | ||
import { createMock } from 'ts-auto-mock'; | ||
import { NameSpaceInterfaceImport } from '../utils/namespace/namespace'; | ||
import Interface = NameSpaceInterfaceImport.Interface; | ||
import SubInterface = NameSpaceInterfaceImport.SubNamespace.SubInterface; | ||
import Enum = NameSpaceInterfaceImport.Enum; | ||
|
||
describe('import equal', () => { | ||
it('should use the correct import for an interface', () => { | ||
const mock: Interface = createMock<Interface>(); | ||
expect(mock.a).toBe(''); | ||
}); | ||
|
||
it('should use the correct import for a literal', () => { | ||
interface InterfaceWithEnumFromModule { | ||
enum: Enum; | ||
} | ||
const mock: InterfaceWithEnumFromModule = createMock<InterfaceWithEnumFromModule>(); | ||
expect(mock.enum).toBe(Enum.A); | ||
}); | ||
|
||
it('should use the correct import for a sub module interface', () => { | ||
const mock: SubInterface = createMock<SubInterface>(); | ||
expect(mock.a).toBe(''); | ||
}); | ||
}); |
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,4 @@ | ||
export interface Interface { | ||
a: string; | ||
b: number; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/transformer/descriptor/utils/interfaces/importAndExport.ts
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,3 @@ | ||
import { Interface as InterfaceAliasExport } from './basic'; | ||
|
||
export { InterfaceAliasExport }; |
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