Skip to content

Commit ffb8d26

Browse files
committed
drop Promise.resolve as async is not neccessary any more
1 parent 7c762ff commit ffb8d26

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/server/plugins/nunjucks/context.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export async function context(request) {
7272
/**
7373
* Returns the context for the devtool. Consumers won't have access to this.
7474
* @param {FormRequest | FormRequestPayload | null} _request
75-
* @returns {Promise<Record<string, unknown> & { assetPath: string, getDxtAssetPath: (asset: string) => string }>}
75+
* @returns {Record<string, unknown> & { assetPath: string, getDxtAssetPath: (asset: string) => string }}
7676
*/
7777
export function devtoolContext(_request) {
7878
const manifestPath = join(config.get('publicDir'), 'assets-manifest.json')
@@ -86,12 +86,12 @@ export function devtoolContext(_request) {
8686
}
8787
}
8888

89-
return Promise.resolve({
89+
return {
9090
assetPath: '/assets',
9191
getDxtAssetPath: (asset = '') => {
9292
return `/${webpackManifest?.[asset] ?? asset}`
9393
}
94-
})
94+
}
9595
}
9696

9797
/**

src/server/plugins/nunjucks/context.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ describe('Nunjucks context', () => {
99
beforeEach(() => jest.resetModules())
1010

1111
describe('Asset path', () => {
12-
it("should include 'assetPath' for GOV.UK Frontend icons", async () => {
13-
const { assetPath } = await devtoolContext(null)
12+
it("should include 'assetPath' for GOV.UK Frontend icons", () => {
13+
const { assetPath } = devtoolContext(null)
1414
expect(assetPath).toBe('/assets')
1515
})
1616
})
1717

1818
describe('Asset helper', () => {
19-
it("should locate 'assets-manifest.json' assets", async () => {
20-
const { getDxtAssetPath } = await devtoolContext(null)
19+
it("should locate 'assets-manifest.json' assets", () => {
20+
const { getDxtAssetPath } = devtoolContext(null)
2121

2222
expect(getDxtAssetPath('example.scss')).toBe(
2323
'/stylesheets/example.xxxxxxx.min.css'
@@ -39,16 +39,16 @@ describe('Nunjucks context', () => {
3939

4040
// Update config for missing manifest
4141
config.set('publicDir', tmpdir())
42-
const { getDxtAssetPath } = await devtoolContext(null)
42+
const { getDxtAssetPath } = devtoolContext(null)
4343

4444
// Uses original paths when missing
4545
expect(getDxtAssetPath('example.scss')).toBe('/example.scss')
4646
expect(getDxtAssetPath('example.mjs')).toBe('/example.mjs')
4747
})
4848
})
4949

50-
it('should return path to unknown assets', async () => {
51-
const { getDxtAssetPath } = await devtoolContext(null)
50+
it('should return path to unknown assets', () => {
51+
const { getDxtAssetPath } = devtoolContext(null)
5252

5353
expect(getDxtAssetPath('')).toBe('/')
5454
expect(getDxtAssetPath('example.jpg')).toBe('/example.jpg')

0 commit comments

Comments
 (0)