Files
wownerogue/test/productGrants.test.js
jwinterm fad2a695bd Wownerogue
A browser-based roguelike synchronized with crypto block timing. A run is a race
against the next block: reach the exit before the block lands, or the house wins.
The same codebase runs the solo dungeon, the social Tavern, and operator-selected
PvP and race rulesets, with separate free and paid leaderboards.

Self-hostable under the MIT License. See README.md to run it, docs/ARCHITECTURE.md
for the design, and docs/DEPLOY.md to operate an instance.
2026-07-27 08:23:01 -04:00

45 lines
1.3 KiB
JavaScript

const ProductGrants = require('../src/payments/productGrants');
describe('product grants', () => {
test('derives credit grants from credit package fields when grants are absent', () => {
const grants = ProductGrants.normalizeProductGrants({ id: 'small', credits: 10, bonus: 2 });
expect(grants).toMatchObject({
credits: 12,
packs: [],
premiumLevel: null
});
});
test('normalizes bundled pack grants and premium tier', () => {
const grants = ProductGrants.normalizeProductGrants({
id: 'bundle',
credits: 10,
grants: {
credits: 15,
packs: ['generated-skins', { id: 'kenney-3d-characters' }, 'bad-pack'],
premiumLevel: 'Supporter'
}
});
expect(grants.credits).toBe(15);
expect(grants.packs.map(p => p.id)).toEqual(['generated-skins', 'kenney-3d-characters']);
expect(grants.premiumLevel).toBe('supporter');
});
test('public summaries omit internal source/expiry fields', () => {
const summary = ProductGrants.publicGrantSummary({
credits: 0,
packs: [{ id: 'iso-dungeon', source: 'operator', expiresAt: '2030-01-01' }],
premiumLevel: null
});
expect(summary).toEqual({
credits: 0,
raceEntries: 0,
packs: ['iso-dungeon'],
premiumLevel: null
});
});
});