Skip to content

Commit

Permalink
Add tests for destroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
aedart committed Sep 28, 2024
1 parent 2f1a643 commit 101f61f
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/browser/packages/core/application/destroy.test.js
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();
});
});
});

0 comments on commit 101f61f

Please sign in to comment.