Skip to content

Commit

Permalink
test(core): fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
estevanbs committed Jun 6, 2024
1 parent d4fa023 commit b238fe7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
1 change: 0 additions & 1 deletion libs/core/src/lib/di/decorators/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ export function Inject<T extends object>(token: Token<T>) {
target,
`index-${index}`
);
return target;
};
}
1 change: 0 additions & 1 deletion libs/core/src/lib/di/decorators/injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ export function Injectable<T extends object>() {
return function (target: T) {
// o target, neste caso, é a classe que está sendo decorada.
Reflect.defineMetadata(INJECTABLE_METADATA_KEY, true, target);
return target;
};
}
8 changes: 4 additions & 4 deletions libs/core/src/lib/di/injector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const API_TOKEN = new InjectionToken<ApiConfig>('api.config');
abstract class Repository {
protected api: string;

constructor(config: ApiConfig) {
protected constructor(config: ApiConfig) {
this.api = config.url;
}

Expand All @@ -34,7 +34,7 @@ class DataRepository extends Repository {
}

abstract class Presenter {
constructor(public repository: Repository) {}
protected constructor(public repository: Repository) {}

abstract getAll(): Promise<unknown[]>;
}
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('Injector', () => {
provide: Presenter,
useFactory: (repo: Repository) => new UiPresenter(repo),
deps: [Repository],
}
},
]);
});

Expand All @@ -73,7 +73,7 @@ describe('Injector', () => {
});

it('should return config object when asking api token', () => {
const config = injector.get<ApiConfig>(API_TOKEN);
const config = injector.get(API_TOKEN);
expect(config).toStrictEqual({
url: 'https://api.clean-architecture.design',
});
Expand Down
2 changes: 1 addition & 1 deletion libs/core/src/lib/di/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Injector {
this.providers.set(provider.provide, provider);
}

static create<T>(providers: Provider<T>[]) {
static create(providers: Provider[]) {
if (!Injector.instance) {
Injector.instance = new Injector(providers);
}
Expand Down

0 comments on commit b238fe7

Please sign in to comment.