Add backend unit/integration tests, Playwright e2e tests, README, cookie Secure fix
SonarQube Analysis / sonarqube (push) Successful in 4m20s

This commit is contained in:
2026-08-13 22:35:38 +00:00
parent 2adbf24b23
commit 921022c658
25 changed files with 6600 additions and 57 deletions
+47
View File
@@ -0,0 +1,47 @@
import { toCents, formatPrice, isValidEmail } from '../../src/utils';
describe('toCents', () => {
it('converts a dollar string to integer cents', () => {
expect(toCents('19.99')).toBe(1999);
});
it('converts a plain number to integer cents', () => {
expect(toCents(5)).toBe(500);
});
it('rounds to the nearest cent', () => {
expect(toCents('19.999')).toBe(2000);
});
it('throws on non-numeric input', () => {
expect(() => toCents('not-a-number')).toThrow('invalid price');
});
it('throws on a negative price', () => {
expect(() => toCents(-5)).toThrow('invalid price');
});
});
describe('formatPrice', () => {
it('formats cents as a dollar string', () => {
expect(formatPrice(1999)).toBe('$19.99');
});
it('pads to two decimal places', () => {
expect(formatPrice(500)).toBe('$5.00');
});
});
describe('isValidEmail', () => {
it('accepts a well-formed email', () => {
expect(isValidEmail('thom@example.com')).toBe(true);
});
it('rejects a string with no @', () => {
expect(isValidEmail('not-an-email')).toBe(false);
});
it('rejects an email with no domain', () => {
expect(isValidEmail('thom@')).toBe(false);
});
});