Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return MakePlural', function() {
expect(MakePlural.load()).to.equal(MakePlural)
})
})
it('should load custom CLDR data', function() {
var cldr = {
supplemental: {
'plurals-type-cardinal': {
xx: {
'pluralRule-count-one':
'n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000',
'pluralRule-count-other':
' @integer 0, 2~16, 100, 1000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, …'
}
}
}
}
MakePlural.load(cldr)
expect(MakePlural.rules).to.have.keys('cardinal', 'ordinal')
expect(MakePlural.rules.cardinal).to.have.key('xx')
})
it('should load default CLDR data', function() {
import { expect } from 'chai'
import cardinalData from 'cldr-core/supplemental/plurals.json'
import ordinalData from 'cldr-core/supplemental/ordinals.json'
import { identifier } from 'safe-identifier'
import MakePlural from 'make-plural-compiler/src/compiler'
import * as Plurals from 'make-plural/plurals'
MakePlural.load(cardinalData, ordinalData)
function testPluralData(type, lc, getPlural) {
var opt = { cardinals: type == 'cardinal', ordinals: type == 'ordinal' }
it('has autogenerated tests', function() {
const mpc = new MakePlural(lc, opt)
expect(() => mpc.compile()).to.not.throw()
expect(mpc.tests[type]).to.not.be.empty
})
it('is included in the output', function() {
expect(getPlural(lc)).to.be.an.instanceOf(Function)
})
var mpc = new MakePlural(lc, opt)
var mp = mpc.compile()
expect(() => MakePlural.load('')).to.throw()
})
expect(() => MakePlural.load(cardinalData, ordinalData)).to.not.throw()
expect(MakePlural.rules).to.have.keys('cardinal', 'ordinal')