/* eslint-env jest */ import { articleCostCredits, formatCredits, generatedFieldsCostCredits, kbDocumentCostNote, regenerateCostCredits, } from '../credit-costs'; describe('credit costs', () => { it('prices each language version of a piece as an article', () => { expect(articleCostCredits(1)).toBe(200); expect(articleCostCredits(3)).toBe(600); expect(articleCostCredits(0)).toBe(200); }); it('prices a regeneration like writing the row again', () => { expect(regenerateCostCredits('blog')).toBe(200); expect(regenerateCostCredits(undefined)).toBe(200); expect(regenerateCostCredits('social')).toBe(25); }); it('prices generated content per field, per product', () => { expect(generatedFieldsCostCredits(12, 2)).toBe(240); expect(generatedFieldsCostCredits(3, 0)).toBe(30); }); it('states the knowledge-base tiers', () => { expect(kbDocumentCostNote()).toBe( 'Each document costs 1 credit up to 10 pages, 5 credits up to 50 pages and 15 credits beyond.' ); }); it('prints the amount the way the buttons say it', () => { expect(formatCredits(250)).toBe('250 credits'); expect(formatCredits(1)).toBe('1 credit'); expect(formatCredits(1200)).toBe('1,200 credits'); }); });