File tree 2 files changed +15
-4
lines changed
packages/nest-utils/src/testing/container
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,19 @@ describe('AppController', () => {
19
19
const response = await supertest . get ( '/' ) ;
20
20
expect ( response . statusCode ) . toBe ( 200 ) ;
21
21
expect ( response . body . message ) . toBe ( 'Hello there!' ) ;
22
+ expect ( response . body . session ) . toBe ( 'Not logged in' ) ;
23
+ } ) ;
24
+
25
+ it ( 'should indicate the current session' , async ( ) => {
26
+ const response = await supertest . get ( '/' , {
27
+ session : {
28
+ sub : '123' ,
29
+ name : 'John Doe' ,
30
+ email : 'john.doe@example.com' ,
31
+ } ,
32
+ } ) ;
33
+ expect ( response . statusCode ) . toBe ( 200 ) ;
34
+ expect ( response . body . session ) . toBe ( 'Logged in as John Doe' ) ;
22
35
} ) ;
23
36
} ) ;
24
37
Original file line number Diff line number Diff line change 1
1
import { INestApplication } from '@nestjs/common' ;
2
2
import { Test , TestingModule } from '@nestjs/testing' ;
3
3
import { type OmitFunctionMembers } from '@spuxx/js-utils' ;
4
- import { AuthOptions , SessionResource } from '../../auth' ;
4
+ import { AuthOptions } from '../../auth' ;
5
5
import { AuthModule } from '../../auth/auth.module' ;
6
6
import { Supertest } from '../supertest' ;
7
7
import { createEndToEndNestApplication } from './private/end-to-end' ;
@@ -96,12 +96,10 @@ export class TestContainer {
96
96
// Enable end-to-end testing if requested
97
97
let app : INestApplication | undefined ;
98
98
let supertest : Supertest | undefined ;
99
- let session : Partial < SessionResource > | undefined ;
100
99
if ( enableEndToEnd ) {
101
100
app = await createEndToEndNestApplication ( module ) ;
102
- session = { ...options . session } ;
103
101
await AuthModule . bootstrap ( app , authOptions as AuthOptions ) ;
104
- supertest = new Supertest ( app , session ) ;
102
+ supertest = new Supertest ( app , options . session ) ;
105
103
}
106
104
// Return the test container
107
105
return new TestContainer ( { module, app, supertest } ) ;
You can’t perform that action at this time.
0 commit comments