Files
API/test/feedback/ratelimit.test.ts
T
Paddy b05f6b9da0
Jenkins Production Deployment
Add Feedback domain module: public submission flow, admin CRUD, reporting (#7)
Co-authored-by: Patrick Müller <mail@pmueller.me>
Reviewed-on: #7
Co-authored-by: Patrick Mueller <patrick@mueller-patrick.tech>
Co-committed-by: Patrick Mueller <patrick@mueller-patrick.tech>
2026-08-23 09:39:02 +00:00

21 lines
581 B
TypeScript

import {hashIp} from '../../src/models/feedback/feedback.ratelimit';
describe('hashIp', () => {
it('never returns the raw IP', () => {
const hash = hashIp('203.0.113.42');
expect(hash).not.toContain('203.0.113.42');
});
it('is deterministic for the same input', () => {
expect(hashIp('203.0.113.42')).toBe(hashIp('203.0.113.42'));
});
it('differs for different inputs', () => {
expect(hashIp('203.0.113.42')).not.toBe(hashIp('203.0.113.43'));
});
it('is a 64-char hex SHA-256 digest', () => {
expect(hashIp('203.0.113.42')).toMatch(/^[0-9a-f]{64}$/);
});
});