@@ -10,14 +10,14 @@ describe('Nunjucks context', () => {
1010
1111 describe ( 'Asset path' , ( ) => {
1212 it ( "should include 'assetPath' for GOV.UK Frontend icons" , ( ) => {
13- const { assetPath } = devtoolContext ( )
13+ const { assetPath } = devtoolContext ( null )
1414 expect ( assetPath ) . toBe ( '/assets' )
1515 } )
1616 } )
1717
1818 describe ( 'Asset helper' , ( ) => {
1919 it ( "should locate 'assets-manifest.json' assets" , ( ) => {
20- const { getDxtAssetPath } = devtoolContext ( )
20+ const { getDxtAssetPath } = devtoolContext ( null )
2121
2222 expect ( getDxtAssetPath ( 'example.scss' ) ) . toBe (
2323 '/stylesheets/example.xxxxxxx.min.css'
@@ -39,7 +39,7 @@ describe('Nunjucks context', () => {
3939
4040 // Update config for missing manifest
4141 config . set ( 'publicDir' , tmpdir ( ) )
42- const { getDxtAssetPath } = devtoolContext ( )
42+ const { getDxtAssetPath } = devtoolContext ( null )
4343
4444 // Uses original paths when missing
4545 expect ( getDxtAssetPath ( 'example.scss' ) ) . toBe ( '/example.scss' )
@@ -48,24 +48,24 @@ describe('Nunjucks context', () => {
4848 } )
4949
5050 it ( 'should return path to unknown assets' , ( ) => {
51- const { getDxtAssetPath } = devtoolContext ( )
51+ const { getDxtAssetPath } = devtoolContext ( null )
5252
53- expect ( getDxtAssetPath ( ) ) . toBe ( '/' )
53+ expect ( getDxtAssetPath ( '' ) ) . toBe ( '/' )
5454 expect ( getDxtAssetPath ( 'example.jpg' ) ) . toBe ( '/example.jpg' )
5555 expect ( getDxtAssetPath ( 'example.gif' ) ) . toBe ( '/example.gif' )
5656 } )
5757 } )
5858
5959 describe ( 'Config' , ( ) => {
60- it ( 'should include environment, phase tag and service info' , ( ) => {
61- expect ( ( ) => context ( null ) ) . toThrow (
60+ it ( 'should include environment, phase tag and service info' , async ( ) => {
61+ await expect ( context ( null ) ) . rejects . toThrow (
6262 'context called before plugin registered'
6363 )
6464 } )
6565 } )
6666
6767 describe ( 'Crumb' , ( ) => {
68- it ( 'should handle malformed requests with missing state' , ( ) => {
68+ it ( 'should handle malformed requests with missing state' , async ( ) => {
6969 // While state should always exist in a valid Hapi request (it holds cookies),
7070 // we've seen malformed requests in production where it's missing
7171 const malformedRequest = /** @type {FormRequest } */ (
@@ -92,14 +92,14 @@ describe('Nunjucks context', () => {
9292 } )
9393 )
9494
95- const { crumb } = context ( malformedRequest )
95+ const { crumb } = await context ( malformedRequest )
9696 expect ( crumb ) . toBeUndefined ( )
9797 expect (
9898 malformedRequest . server . plugins . crumb . generate
9999 ) . not . toHaveBeenCalled ( )
100100 } )
101101
102- it ( 'should generate crumb when state exists' , ( ) => {
102+ it ( 'should generate crumb when state exists' , async ( ) => {
103103 const mockCrumb = 'generated-crumb-value'
104104 const validRequest = /** @type {FormRequest } */ (
105105 /** @type {unknown } */ ( {
@@ -125,7 +125,7 @@ describe('Nunjucks context', () => {
125125 } )
126126 )
127127
128- const { crumb } = context ( validRequest )
128+ const { crumb } = await context ( validRequest )
129129 expect ( crumb ) . toBe ( mockCrumb )
130130 expect ( validRequest . server . plugins . crumb . generate ) . toHaveBeenCalledWith (
131131 validRequest
0 commit comments