@chuxingpay/basic
Version:
package contains general json data such as currency codes, bed types, facility type, bank list, branch/group list etc.
96 lines (79 loc) • 2.65 kB
JavaScript
const { expect } = require('chai')
const BankMap = require('../es/BankMap')
const {
CurrencyMap,
BrandMap,
HttpCodeMap
} = require('../index')
describe('@chuxingpay/npm/basic', () => {
describe('#CurrencyMap', () => {
it('should has data', () => {
const list = CurrencyMap.list
expect(list).to.be.an('array')
expect(list.length).to.equal(31)
})
it('should return codes', () => {
const codes = CurrencyMap.codes
expect(codes).to.be.an('array').that.includes('CNY')
})
it('$find return a list', () => {
const list = CurrencyMap.find('USD')
expect(list).to.be.an('array')
expect(list[0]).to.have.property('name', '美元')
})
it('$findOne return an object', () => {
const match = CurrencyMap.findOne('CAD')
expect(match).to.be.an('object').that.have.property('symbol', '$')
})
it('$findOne return empty if no match', () => {
const match =CurrencyMap.findOne('BCD')
expect(match).to.be.an('object').that.to.be.empty
})
it('$codeToSymbol return match', () => {
const symbol = CurrencyMap.codeToSymbol('USD')
expect(symbol).to.eq('$')
})
it('$codeToSymbol return empty', () => {
const symbol = CurrencyMap.codeToSymbol('WDD')
expect(symbol).to.eq('')
})
it('$symbolToCode return match', () => {
const code = CurrencyMap.symbolToCode('¥')
expect(code).to.eq('CNY')
})
it('$symbolToCode return empty', () => {
const code = CurrencyMap.symbolToCode('ç')
expect(code).to.eq('')
})
})
describe('#BankMap', () => {
it('should has data', () => {
expect(Array.isArray(BankMap)).to.be.true
})
})
describe('#BrandMap', () => {
it('should has data', () => {
const list = BrandMap.list;
expect(list).to.be.an('array')
})
it('$findOne return an object', () => {
const match = BrandMap.findOne('7天酒店')
expect(match).to.be.an('object').that.have.property('nameEn', '7Days Inn')
})
it('$findByLevel return an array', () => {
const match = BrandMap.findByLevel(0)
expect(match).to.be.an('array')
expect(match[0]).to.have.property('level', 0)
})
})
describe('#HttpCodeMap', () => {
it('should has data', () => {
const list = HttpCodeMap.list
expect(list).to.be.an('array')
})
it('$findOne return an object', () => {
const result = HttpCodeMap.findOne(422)
expect(result).to.be.an('object').that.have.property('description', 'The request was well-formed but was unable to be followed due to semantic errors.')
})
})
})