Skip to main content

max / makenotwork

1.1 KB · 27 lines History Blame Raw
1 import { test } from 'node:test';
2 import assert from 'node:assert/strict';
3 import { priceFor, formatMonthly } from './price-mode.logic.ts';
4
5 test('priceFor picks the price the mode names', () => {
6 const prices = { std: '16', founder: '8' };
7 assert.equal(priceFor(prices, 'founder'), '8');
8 assert.equal(priceFor(prices, 'list'), '16');
9 });
10
11 test('priceFor returns null when the card lacks that price', () => {
12 // A page rendered with the founder window shut carries no founder value.
13 assert.equal(priceFor({ std: '16', founder: null }, 'founder'), null);
14 assert.equal(priceFor({ std: null, founder: '8' }, 'list'), null);
15 });
16
17 test('priceFor treats an empty attribute as absent', () => {
18 // getAttribute on a present-but-empty attribute returns '', not null, and
19 // writing that into the radio value would send an empty tier price.
20 assert.equal(priceFor({ std: '', founder: '8' }, 'list'), null);
21 });
22
23 test('formatMonthly matches what the server renders', () => {
24 assert.equal(formatMonthly('16'), '$16/mo');
25 assert.equal(formatMonthly('8'), '$8/mo');
26 });
27