-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(adapters.nestjs): support primitive value type in dependencies (#56
- Loading branch information
Showing
15 changed files
with
81 additions
and
10 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
File renamed without changes.
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,36 @@ | ||
import { forwardRef, Inject } from '@nestjs/common'; | ||
|
||
export class DependencyOne { | ||
print(): string { | ||
return 'dependencyOne'; | ||
} | ||
} | ||
|
||
export class DependencyTwo { | ||
print(): string { | ||
return 'dependencyTwo'; | ||
} | ||
} | ||
|
||
export class DependencyThree { | ||
print(): string { | ||
return 'dependencyThree'; | ||
} | ||
} | ||
|
||
export class DependencyFourToken { | ||
print(): string { | ||
return 'dependencyFour'; | ||
} | ||
} | ||
|
||
export class MainClass { | ||
public constructor( | ||
private readonly dependencyOne: DependencyOne, | ||
private readonly dependencyTwo: DependencyTwo, | ||
@Inject(forwardRef(() => DependencyThree)) private readonly dependencyThree: DependencyThree, | ||
@Inject('CUSTOM_TOKEN') private readonly dependencyFour: DependencyFourToken, | ||
@Inject('LITERAL_VALUE_ARR') private readonly literalValueArray: string[], | ||
@Inject('LITERAL_VALUE_STR') private readonly literalValueString: string | ||
) {} | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/adapters/nestjs/__test__/nestjs-adapter.integration.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ReflectorFactory } from '../src/reflector.service'; | ||
import { TokensReflector } from '../src/token-reflector.service'; | ||
import { | ||
DependencyFourToken, | ||
DependencyOne, | ||
DependencyThree, | ||
DependencyTwo, | ||
MainClass, | ||
} from './integration.assets'; | ||
import { Type } from '@automock/types'; | ||
import { ClassDependencies, PrimitiveValue } from '@automock/common'; | ||
|
||
describe('NestJS Automock Adapter Integration Test', () => { | ||
describe('reflecting a class', () => { | ||
const reflectorFactory = ReflectorFactory(Reflect, TokensReflector); | ||
const classDependencies = reflectorFactory.reflectDependencies(MainClass); | ||
|
||
it('should return a map of the class dependencies', () => { | ||
expect(classDependencies).toStrictEqual<ClassDependencies>( | ||
new Map<Type | string, PrimitiveValue | Type>([ | ||
['CUSTOM_TOKEN', DependencyFourToken], | ||
[DependencyOne, DependencyOne], | ||
[DependencyTwo, DependencyTwo], | ||
[DependencyThree, DependencyThree], | ||
['LITERAL_VALUE_ARR', Array], | ||
['LITERAL_VALUE_STR', String], | ||
]) | ||
); | ||
}); | ||
}); | ||
}); |
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 DependenciesReflector from './src'; | ||
|
||
export = DependenciesReflector |
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
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions
10
...eflectors/nestjs/src/reflector.service.ts → .../adapters/nestjs/src/reflector.service.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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.