-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
219 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { formatNumber, parseNumber, formatDate, parseDate, firstDay, weekendRange, setData } from '../src/main'; | ||
import { LOCALES, NO_CURRENCY_LOCALE, clean } from './utils'; | ||
|
||
describe('generated-locales', () => { | ||
const date = new Date(2000, 0, 1); | ||
const number = 5.55; | ||
const numberString = '5.55'; | ||
|
||
describe.each(LOCALES)('%s (all)', (locale) => { | ||
beforeAll(() => { | ||
const all = require(`./locales/${ locale }/all`).default; | ||
setData(all); | ||
}); | ||
|
||
afterAll(() => { | ||
clean(); | ||
}); | ||
|
||
it('format number', () => { | ||
expect(() => { | ||
formatNumber(number, 'n', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('parse number', () => { | ||
expect(() => { | ||
parseNumber(numberString, locale, 'n'); | ||
}).not.toThrow(); | ||
}); | ||
|
||
if (locale !== NO_CURRENCY_LOCALE) { | ||
it('format currency', () => { | ||
expect(() => { | ||
formatNumber(number, 'c', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('parse currency', () => { | ||
expect(() => { | ||
parseNumber(numberString, locale, 'c'); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('format accounting', () => { | ||
expect(() => { | ||
formatNumber(number, 'a', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('parse accounting', () => { | ||
expect(() => { | ||
parseNumber(numberString, locale, 'a'); | ||
}).not.toThrow(); | ||
}); | ||
} | ||
|
||
it('format date', () => { | ||
expect(() => { | ||
formatDate(date, 'F', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('parse date', () => { | ||
expect(() => { | ||
parseDate(formatDate(date, 'F'), 'F', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('firstDay', () => { | ||
expect(() => { | ||
firstDay(locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('weekendRange', () => { | ||
expect(() => { | ||
weekendRange(locale); | ||
}).not.toThrow(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { formatDate, parseDate, firstDay, weekendRange, setData } from '../src/main'; | ||
import { LOCALES, clean } from './utils'; | ||
|
||
describe('generated-locales', () => { | ||
const date = new Date(2000, 0, 1); | ||
|
||
describe.each(LOCALES)('%s (calendar)', (locale) => { | ||
beforeAll(() => { | ||
const calendar = require(`./locales/${ locale }/calendar`).default; | ||
setData(calendar); | ||
}); | ||
|
||
afterAll(() => { | ||
clean(); | ||
}); | ||
|
||
it('format', () => { | ||
expect(() => { | ||
formatDate(date, 'F', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('parse', () => { | ||
expect(() => { | ||
parseDate(formatDate(date, 'F'), 'F', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('firstDay', () => { | ||
expect(() => { | ||
firstDay(locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('weekendRange', () => { | ||
expect(() => { | ||
weekendRange(locale); | ||
}).not.toThrow(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { formatNumber, parseNumber, setData } from '../src/main'; | ||
import { LOCALES, clean, NO_CURRENCY_LOCALE } from './utils'; | ||
|
||
const number = 5.55; | ||
const numberString = '5.55'; | ||
const currencyLocales = LOCALES.filter(locale => locale !== NO_CURRENCY_LOCALE); | ||
|
||
describe.each(currencyLocales)('%s currency', (locale) => { | ||
beforeAll(() => { | ||
const numbers = require(`./locales/${ locale }/numbers`).default; | ||
const currencies = require(`./locales/${ locale }/currencies`).default; | ||
|
||
setData(numbers); | ||
setData(currencies); | ||
|
||
}); | ||
|
||
afterAll(() => { | ||
clean(); | ||
}); | ||
|
||
it('format', () => { | ||
expect(() => { | ||
formatNumber(number, 'c', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('parse', () => { | ||
expect(() => { | ||
parseNumber(numberString, locale, 'c'); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('format accounting', () => { | ||
expect(() => { | ||
formatNumber(number, 'a', locale); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('parse accounting', () => { | ||
expect(() => { | ||
parseNumber(numberString, locale, 'a'); | ||
}).not.toThrow(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.