Migrate tests to Vitest

This commit is contained in:
Mike Cao committed 2026-05-14 22:05:34 -07:00
1 parent cbe4d79b3c
commit c0ea3aefbe
15 files changed
+1393 -1839

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import { expect, test } from 'vitest';
import { getIpAddress } from './ip';
const IP = '127.0.0.1';
test('getIpAddress: Custom header', () => {
process.env.CLIENT_IP_HEADER = 'x-custom-ip-header';
expect(getIpAddress(new Headers({ 'x-custom-ip-header': IP }))).toEqual(IP);
});
test('getIpAddress: CloudFlare header', () => {
expect(getIpAddress(new Headers({ 'cf-connecting-ip': IP }))).toEqual(IP);
});
test('getIpAddress: Standard header', () => {
expect(getIpAddress(new Headers({ 'x-forwarded-for': IP }))).toEqual(IP);
});
test('getIpAddress: No header', () => {
expect(getIpAddress(new Headers())).toEqual(undefined);
});