File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ export class App {
146146 app . close = ( ) => {
147147 debug ( "closing all components" ) ;
148148 return Promise . all (
149- components . map ( ( component ) => component . close ( ) ) ,
149+ allComponents . map ( ( component ) => component . close ( ) ) ,
150150 ) . then ( ) ;
151151 } ;
152152
Original file line number Diff line number Diff line change 1+ import { describe , it } from "node:test" ;
2+ import * as assert from "node:assert" ;
3+ import { App , type AppInit , Component } from "../../src" ;
4+ import { createTestDB } from "../setup.js" ;
5+
6+ describe ( "App" , ( ) => {
7+ it ( "should initialize and close components" , async ( ) => {
8+ let initCalled = false ;
9+ let closeCalled = false ;
10+
11+ class TestComponent extends Component {
12+ override async init ( ) {
13+ initCalled = true ;
14+ }
15+
16+ override async close ( ) {
17+ closeCalled = true ;
18+ }
19+ }
20+
21+ const app = await App . create ( {
22+ components : [ createTestDB ( ) ] ,
23+ modules : [
24+ {
25+ name : "test" ,
26+ version : "0.0.1" ,
27+ init ( app : AppInit ) {
28+ app . component ( TestComponent ) ;
29+ } ,
30+ } ,
31+ ] ,
32+ } ) ;
33+
34+ assert . equal ( initCalled , true ) ;
35+ assert . equal ( closeCalled , false ) ;
36+
37+ await app . close ( ) ;
38+
39+ assert . equal ( closeCalled , true ) ;
40+ } ) ;
41+ } ) ;
You can’t perform that action at this time.
0 commit comments