Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Oct 14, 2024
1 parent ce6e3cf commit 6a2ae1f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/astro/test/units/routing/api-context.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { createContext } from '../../../dist/core/middleware/index.js';

describe('createAPIContext', () => {
it('should return the clientAddress', () => {
const request = new Request('http://example.com', {
headers: {
'x-forwarded-for': '192.0.2.43, 172.16.58.3',
},
});

const context = createContext({
request,
});

assert.equal(context.clientAddress, '192.0.2.43');
});
});

0 comments on commit 6a2ae1f

Please sign in to comment.