refactor(core): Enforce range for shutdown priority (no-changelog) (#9944)

This commit is contained in:
Iván Ovejero
2024-07-04 20:26:11 +02:00
committed by GitHub
parent c82579bf76
commit 757feaf585
6 changed files with 42 additions and 9 deletions

View File

@@ -73,4 +73,26 @@ describe('OnShutdown', () => {
new TestClass();
}).toThrow('TestClass.onShutdown() must be a method on TestClass to use "OnShutdown"');
});
it('should throw if the priority is invalid', () => {
expect(() => {
@Service()
class TestClass {
@OnShutdown(201)
async onShutdown() {}
}
new TestClass();
}).toThrow('Invalid shutdown priority. Please set it between 0 and 200.');
expect(() => {
@Service()
class TestClass {
@OnShutdown(-1)
async onShutdown() {}
}
new TestClass();
}).toThrow('Invalid shutdown priority. Please set it between 0 and 200.');
});
});