-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Application } from "@aedart/core"; | ||
|
||
describe('@aedart/core', () => { | ||
describe('destroy', () => { | ||
|
||
it('can destroy application', async () => { | ||
|
||
const identifier = Symbol('my_instance'); | ||
class A {} | ||
|
||
const app = new Application(); | ||
|
||
// ------------------------------------------------------------------------------- // | ||
|
||
app.bind(identifier, A); | ||
|
||
await app.run(); | ||
|
||
app.destroy(); | ||
|
||
// ------------------------------------------------------------------------------- // | ||
|
||
expect(app.isRunning()) | ||
.withContext('application should NOT be running') | ||
.toBeFalse(); | ||
|
||
expect(app.hasBooted()) | ||
.withContext('application should NOT be booted') | ||
.toBeFalse(); | ||
|
||
expect(app.hasBeenBootstrapped()) | ||
.withContext('application should NOT be bootstrapped') | ||
.toBeFalse(); | ||
|
||
expect(app.bound(identifier)) | ||
.withContext('application should NOT have any bindings') | ||
.toBeFalse(); | ||
}); | ||
|
||
it('invokes destroy callbacks', () => { | ||
const app = new Application(); | ||
|
||
let invoked = false; | ||
const callback = () => { | ||
invoked = true; | ||
} | ||
|
||
// ------------------------------------------------------------------------------- // | ||
|
||
app | ||
.destroying(callback) | ||
.destroy(); | ||
|
||
expect(invoked) | ||
.withContext('destroy callback not invoked') | ||
.toBeTrue(); | ||
}); | ||
}); | ||
}); |