Files
website/src/lib/price-trackers.test.ts
T
stan 81b0c51672
Deploy production / deploy (push) Successful in 1m30s
prices: fold groceries and CS skins into one price tracker (/trackers/prices) with tabs
- tab registry in #lib/price-trackers (add a tab = route + entry + icon)
- groceries -> /trackers/prices/groceries (owner-only), CS prices -> /trackers/prices/cs (public)
- old /trackers/groceries/* and /projects/cs-prices/* redirect (301 GET, 308 POST) with query
- nav: one prices entry replaces groceries and skins; cyan price-tag icon
2026-10-27 10:38:10 +00:00

30 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { defaultPriceTab, legacyPriceRedirect, visiblePriceTabs } from './price-trackers';
describe('price tracker', () => {
it('redirects old groceries and CS prices URLs with their sub-paths', () => {
expect(legacyPriceRedirect('/trackers/groceries')).toEqual({
to: '/trackers/prices/groceries',
private: true
});
expect(legacyPriceRedirect('/trackers/groceries/stats')?.to).toBe(
'/trackers/prices/groceries/stats'
);
expect(legacyPriceRedirect('/projects/cs-prices/ak-47-redline')).toEqual({
to: '/trackers/prices/cs/ak-47-redline',
private: false
});
expect(legacyPriceRedirect('/projects/cs-prices/api/series')?.to).toBe(
'/trackers/prices/cs/api/series'
);
expect(legacyPriceRedirect('/trackers/groceriesx')).toBeNull();
expect(legacyPriceRedirect('/trackers/prices/cs')).toBeNull();
});
it('hides private tabs from everyone but the owner', () => {
expect(visiblePriceTabs(false).map((t) => t.slug)).toEqual(['cs']);
expect(visiblePriceTabs(true).map((t) => t.slug)).toEqual(['groceries', 'cs']);
expect(defaultPriceTab(false).slug).toBe('cs');
expect(defaultPriceTab(true).slug).toBe('groceries');
});
});