-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
34 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { Container } from "internal:typedi"; | ||
import { createFakeClassDecoratorContext } from "./utils/fake-context.util"; | ||
import { ESService } from "internal:typedi/contrib/es/es-service.decorator.mjs"; | ||
import { Container } from 'internal:typedi'; | ||
import { createFakeClassDecoratorContext } from './utils/fake-context.util'; | ||
import { ESService } from 'internal:typedi/contrib/es/es-service.decorator.mjs'; | ||
|
||
// Due to the testing structure, we can't actually use ES Decorators | ||
// here. Instead, we have to pretend we're using them, by manually | ||
// passing descriptors and functions to them. | ||
// P.S. The actual conformance testing goes on in <test/decorators/Service.spec.ts> | ||
// This suite just tests parts of required ESService-specific testing. | ||
describe('ESService', () => { | ||
beforeEach(() => Container.reset({ strategy: 'resetValue' })); | ||
beforeEach(() => Container.reset({ strategy: 'resetValue' })); | ||
|
||
// Note: in <test/contrib/es/utils/es-service-decorator-wrapper.util.ts>, we already test | ||
// if the implementation accepts valid invocations with valid ClassDecoratorContext objects. | ||
it('should fail if not passed a ClassDecoratorContext', () => { | ||
class MyService { } | ||
// Note: in <test/contrib/es/utils/es-service-decorator-wrapper.util.ts>, we already test | ||
// if the implementation accepts valid invocations with valid ClassDecoratorContext objects. | ||
it('should fail if not passed a ClassDecoratorContext', () => { | ||
class MyService {} | ||
|
||
const context = createFakeClassDecoratorContext(MyService); | ||
expect(() => ESService([ ])(class { }, context)).not.toThrow(); | ||
}); | ||
const context = createFakeClassDecoratorContext(MyService); | ||
expect(() => ESService([])(class {}, context)).not.toThrow(); | ||
}); | ||
}); |
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,12 +1,14 @@ | ||
export function createFakeClassDecoratorContext<TFunction extends Function>(targetConstructor: TFunction): ClassDecoratorContext<abstract new (...args: any) => any> { | ||
return { | ||
addInitializer(initializer) { | ||
// We can't implement this, and it isn't used by ESService. | ||
throw new Error('Not implemented.'); | ||
}, | ||
kind: 'class', | ||
// TODO: Not sure what goes here, and it isn't used by ESService. | ||
metadata: {}, | ||
name: targetConstructor.name | ||
}; | ||
} | ||
export function createFakeClassDecoratorContext<TFunction extends Function>( | ||
targetConstructor: TFunction | ||
): ClassDecoratorContext<abstract new (...args: any) => any> { | ||
return { | ||
addInitializer(initializer) { | ||
// We can't implement this, and it isn't used by ESService. | ||
throw new Error('Not implemented.'); | ||
}, | ||
kind: 'class', | ||
// TODO: Not sure what goes here, and it isn't used by ESService. | ||
metadata: {}, | ||
name: targetConstructor.name, | ||
}; | ||
} |
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