File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
- import { describe , it } from "../lib/std/testing.ts" ;
1
+ import { beforeEach , describe , it } from "../lib/std/testing.ts" ;
2
+ import { assertEquals } from "../lib/std/assert.ts" ;
2
3
import { ConsoleLogger } from "./logging.ts" ;
3
4
import { assert } from "../lib/std/assert.ts" ;
4
5
5
6
describe ( "ConsoleLogger" , ( ) => {
7
+ let output = "" ;
8
+
9
+ beforeEach ( ( ) => {
10
+ globalThis . console = new Proxy ( globalThis . console , {
11
+ get : ( ) => {
12
+ return ( data : unknown ) => {
13
+ output += data ;
14
+ } ;
15
+ } ,
16
+ } ) ;
17
+ } ) ;
18
+
6
19
it ( "should be a writable stream" , ( ) => {
7
20
const logger = new ConsoleLogger ( ) ;
8
21
assert ( logger instanceof WritableStream ) ;
9
22
} ) ;
23
+
10
24
it ( "should log to console" , async ( ) => {
11
- // TODO: Stub console.log
12
25
const logger = new ConsoleLogger ( ) ;
13
26
await logger . getWriter ( ) . write ( "ConsoleLogger" ) ;
27
+ assertEquals ( output , "ConsoleLogger" ) ;
14
28
} ) ;
15
29
} ) ;
You can’t perform that action at this time.
0 commit comments