Skip to content

Commit

Permalink
Add test for before() and after()
Browse files Browse the repository at this point in the history
  • Loading branch information
aedart committed Apr 2, 2024
1 parent eaa28a3 commit dacc5c6
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Container } from "@aedart/container";

describe('@aedart/support/container', () => {
describe('before / after', () => {

it('invokes resolved callbacks', () => {
const container = new Container();

let beforeInvoked = false;
let afterInvoked = false;

class Service {}
container
.bind('api', Service)
.before('api', () => {
beforeInvoked = true;
})
.after('api', () => {
afterInvoked = true;
});


// ----------------------------------------------------------------- //

const result = container.make('api');

expect(result)
.toBeInstanceOf(Service);

expect(beforeInvoked)
.withContext('before callback not invoked')
.toBeTrue();

expect(afterInvoked)
.withContext('after callback not invoked')
.toBeTrue();
});
});
});

0 comments on commit dacc5c6

Please sign in to comment.