11import NHSLoginAuthProvider from "@src/app/api/auth/[...nextauth]/provider" ;
2+ import { DeployEnvironment } from "@src/types/environments" ;
23import config from "@src/utils/config" ;
34import { ConfigMock , configBuilder } from "@test-data/config/builders" ;
45
@@ -10,7 +11,10 @@ describe("provider", () => {
1011
1112 describe ( "not using fake NHS login" , ( ) => {
1213 beforeEach ( ( ) => {
13- const defaultConfig = configBuilder ( ) . withNhsLoginUrl ( new URL ( "https://abc" ) ) . build ( ) ;
14+ const defaultConfig = configBuilder ( )
15+ . withNhsLoginUrl ( new URL ( "https://abc" ) )
16+ . andDeployEnvironment ( DeployEnvironment . preprod )
17+ . build ( ) ;
1418 Object . assign ( mockedConfig , defaultConfig ) ;
1519 } ) ;
1620
@@ -24,12 +28,16 @@ describe("provider", () => {
2428 } ) ;
2529
2630 describe ( "using fake NHS login" , ( ) => {
27- beforeEach ( ( ) => {
31+ it ( "should not use NONCE check when using fake login port" , async ( ) => {
2832 const defaultConfig = configBuilder ( ) . withNhsLoginUrl ( new URL ( "https://abc:9123" ) ) . build ( ) ;
2933 Object . assign ( mockedConfig , defaultConfig ) ;
34+ const provider = await NHSLoginAuthProvider ( ) ;
35+ expect ( provider . checks ) . toEqual ( [ "state" ] ) ;
3036 } ) ;
3137
32- it ( "should not use NONCE check" , async ( ) => {
38+ it ( "should not use NONCE check when in test environment" , async ( ) => {
39+ const defaultConfig = configBuilder ( ) . withDeployEnvironment ( DeployEnvironment . test ) . build ( ) ;
40+ Object . assign ( mockedConfig , defaultConfig ) ;
3341 const provider = await NHSLoginAuthProvider ( ) ;
3442 expect ( provider . checks ) . toEqual ( [ "state" ] ) ;
3543 } ) ;
0 commit comments