Skip to content

Commit

Permalink
fix: remove "already registered" warning, which triggered too many fa…
Browse files Browse the repository at this point in the history
…lse positives (#211)

* fix: remove "already registered" warning, which triggered too many false positives

* remove warn test
  • Loading branch information
Skn0tt committed Dec 6, 2022
1 parent 2579e10 commit 38b25ed
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
8 changes: 0 additions & 8 deletions src/registry.test.ts
Expand Up @@ -16,14 +16,6 @@ test('class registry', () => {

expect(() => registry.register(Car)).not.toThrow();

const warnSpy = jest.spyOn(console, 'debug');

registry.register(class Car {});
expect(warnSpy).toHaveBeenCalledTimes(1);
expect(warnSpy.mock.calls[0][0]).toContain(
'Ambiguous class "Car", provide a unique identifier.'
);

registry.register(class Car {}, 'car2');

expect(registry.getValue('car2')).not.toBeUndefined();
Expand Down
9 changes: 0 additions & 9 deletions src/registry.ts
Expand Up @@ -14,15 +14,6 @@ export class Registry<T> {
identifier = this.generateIdentifier(value);
}

if (process.env.NODE_ENV !== 'production') {
const alreadyRegistered = this.kv.getByKey(identifier);
if (alreadyRegistered && alreadyRegistered !== value) {
console.debug(
`Ambiguous class "${identifier}", provide a unique identifier.`
);
}
}

this.kv.set(identifier, value);
}

Expand Down

0 comments on commit 38b25ed

Please sign in to comment.