mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
aa480a2663
[web] migrate from window attributes to getMeta GitOrigin-RevId: 3dcf1ab6b01155e5e4abeb3e78d0fa9053e055bc
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { expect } from 'chai'
|
|
import { formatPriceForDisplayData } from '../../../../../frontend/js/features/subscription/util/recurly-pricing'
|
|
import { formatCurrencyLocalized } from '@/shared/utils/currency'
|
|
|
|
describe('formatPriceForDisplayData', function () {
|
|
it('should handle no tax rate', function () {
|
|
const data = formatPriceForDisplayData(
|
|
'1000',
|
|
0,
|
|
'USD',
|
|
'en',
|
|
formatCurrencyLocalized
|
|
)
|
|
expect(data).to.deep.equal({
|
|
totalForDisplay: '$1,000',
|
|
totalAsNumber: 1000,
|
|
subtotal: '$1,000.00',
|
|
tax: '$0.00',
|
|
includesTax: false,
|
|
})
|
|
})
|
|
|
|
it('should handle a tax rate', function () {
|
|
const data = formatPriceForDisplayData(
|
|
'380',
|
|
0.2,
|
|
'EUR',
|
|
'en',
|
|
formatCurrencyLocalized
|
|
)
|
|
expect(data).to.deep.equal({
|
|
totalForDisplay: '€456',
|
|
totalAsNumber: 456,
|
|
subtotal: '€380.00',
|
|
tax: '€76.00',
|
|
includesTax: true,
|
|
})
|
|
})
|
|
|
|
it('should handle total with cents', function () {
|
|
const data = formatPriceForDisplayData(
|
|
'8',
|
|
0.2,
|
|
'EUR',
|
|
'en',
|
|
formatCurrencyLocalized
|
|
)
|
|
expect(data).to.deep.equal({
|
|
totalForDisplay: '€9.60',
|
|
totalAsNumber: 9.6,
|
|
subtotal: '€8.00',
|
|
tax: '€1.60',
|
|
includesTax: true,
|
|
})
|
|
})
|
|
})
|