Skip to content

Commit 108c8c9

Browse files
committed
Add unit test for maxAge cors headers
1 parent cfc2693 commit 108c8c9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/deploy/events/apiGateway/validate.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,29 @@ describe('#httpValidate()', () => {
413413
expect(validated.events).to.be.an('Array').with.length(1);
414414
expect(validated.events[0].http.cors.methods).to.deep.equal(['POST', 'OPTIONS']);
415415
});
416+
417+
it('should set cors Access-Control-Max-Age headers', () => {
418+
serverlessStepFunctions.serverless.service.stepFunctions = {
419+
stateMachines: {
420+
first: {
421+
events: [
422+
{
423+
http: {
424+
method: 'POST',
425+
path: '/foo/bar',
426+
cors: {
427+
origin: '*',
428+
maxAge: 86400,
429+
},
430+
},
431+
},
432+
],
433+
},
434+
},
435+
};
436+
437+
const validated = serverlessStepFunctions.httpValidate();
438+
expect(validated.events[0].http.cors.origin).to.equal('*');
439+
expect(validated.events[0].http.cors.maxAge).to.equal(86400);
440+
});
416441
});

0 commit comments

Comments
 (0)