From 19eaf0236582a2443ba88319dc83b43359347ef2 Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Mon, 11 May 2026 00:49:29 -0700 Subject: [PATCH] test(uws-platform): assert HEAD route registration on single-call static-asset tests The static-asset implementation registers both GET and HEAD routes (uws-platform.adapter.ts:822-823), but the six single-call tests in the 'static assets' describe block only asserted the GET registration - so a refactor that accidentally dropped the HEAD line would have passed the test suite. Each of the six tests now asserts toHaveBeenCalledTimes(2) plus the corresponding HEAD registration alongside the GET one. The multi-call test that already verified the 4-registration shape and the error-path tests (no registrations to assert) are unchanged. All 66 tests in the file still pass. Closes #82 --- .../platform/uws-platform.adapter.spec.ts | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/http/platform/uws-platform.adapter.spec.ts b/src/http/platform/uws-platform.adapter.spec.ts index 4455717..30eabfa 100644 --- a/src/http/platform/uws-platform.adapter.spec.ts +++ b/src/http/platform/uws-platform.adapter.spec.ts @@ -534,15 +534,19 @@ describe('UwsPlatformAdapter', () => { it('should enable static assets and register catch-all route', () => { adapter.useStaticAssets('/public'); - // Should register a GET route for /* + // Should register both GET and HEAD routes for /* + expect(mockRegistry.register).toHaveBeenCalledTimes(2); expect(mockRegistry.register).toHaveBeenCalledWith('GET', '/*', expect.any(Function)); + expect(mockRegistry.register).toHaveBeenCalledWith('HEAD', '/*', expect.any(Function)); }); it('should respect silent option and not log', () => { adapter.useStaticAssets('/public', { silent: true }); - // Should still register the route + // Should still register both GET and HEAD routes + expect(mockRegistry.register).toHaveBeenCalledTimes(2); expect(mockRegistry.register).toHaveBeenCalledWith('GET', '/*', expect.any(Function)); + expect(mockRegistry.register).toHaveBeenCalledWith('HEAD', '/*', expect.any(Function)); }); it('should register static assets route when custom options provided', () => { @@ -551,8 +555,10 @@ describe('UwsPlatformAdapter', () => { etag: false, }); - // Should register the route + // Should register both GET and HEAD routes + expect(mockRegistry.register).toHaveBeenCalledTimes(2); expect(mockRegistry.register).toHaveBeenCalledWith('GET', '/*', expect.any(Function)); + expect(mockRegistry.register).toHaveBeenCalledWith('HEAD', '/*', expect.any(Function)); }); it('should register multiple static asset routes when called multiple times', () => { @@ -572,22 +578,28 @@ describe('UwsPlatformAdapter', () => { it('should support prefix option for scoped static routes', () => { adapter.useStaticAssets('/public', { prefix: '/assets' }); - // Should register route with prefix + // Should register both GET and HEAD routes with the prefix + expect(mockRegistry.register).toHaveBeenCalledTimes(2); expect(mockRegistry.register).toHaveBeenCalledWith('GET', '/assets/*', expect.any(Function)); + expect(mockRegistry.register).toHaveBeenCalledWith('HEAD', '/assets/*', expect.any(Function)); }); it('should normalize prefix by removing trailing slash', () => { adapter.useStaticAssets('/public', { prefix: '/assets/' }); - // Should register route with normalized prefix (no trailing slash) + // Should register both GET and HEAD routes with normalized prefix (no trailing slash) + expect(mockRegistry.register).toHaveBeenCalledTimes(2); expect(mockRegistry.register).toHaveBeenCalledWith('GET', '/assets/*', expect.any(Function)); + expect(mockRegistry.register).toHaveBeenCalledWith('HEAD', '/assets/*', expect.any(Function)); }); it('should handle empty prefix by using default catch-all', () => { adapter.useStaticAssets('/public', { prefix: '' }); - // Should register default catch-all route + // Should register both GET and HEAD default catch-all routes + expect(mockRegistry.register).toHaveBeenCalledTimes(2); expect(mockRegistry.register).toHaveBeenCalledWith('GET', '/*', expect.any(Function)); + expect(mockRegistry.register).toHaveBeenCalledWith('HEAD', '/*', expect.any(Function)); }); it('should throw error for invalid path (non-string)', () => {