Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Dec 14, 2021
1 parent 4cd8013 commit 4711344
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,29 @@ describe('CORS middleware', () => {
});


it('should pass through OPTIONS requests if no Origin header was set', async () => {

const options = {
allowOrigin: ['https://example.org'],
allowHeaders: ['Content-Type', 'Accept'],
allowMethods: ['GET', 'POST'],
exposeHeaders: ['Link', 'Date']
};
const headers = {};
const app = new Application;
app.use(cors(options));

app.use( ctx => {

ctx.status = 200;
ctx.response.body = ctx.method;

});

const response = await app.subRequest('OPTIONS', '/', headers);
expect(response.status).to.equal(200);
expect(response.body).to.equal('OPTIONS');

});

});

0 comments on commit 4711344

Please sign in to comment.