UNPKG

@nahanil/zhdict-lite

Version:

Access extended CC-CEDICT dictionary data

65 lines (61 loc) 1.91 kB
const cedict = require('../') describe('search', () => { it('Should return expected result(s)', (done) => { cedict.search('水').then((result) => { expect(result.length).toBe(1) expect(result[0]).toMatchObject({ id: '3f69904700c4fe2fb2caeb3f46501bc66ce245a4', simplified: '水', traditional: '水', pinyin: 'shui3', hskLevel: 1, radicalSimplified: '水', radicalTraditional: '水', strokesSimplified: 4, strokesTraditional: 4, strokesMinRadSimplified: 0, strokesMinRadTraditional: 0, variantsSimplified: null, variantsTraditional: null, variants: '氵' }) expect(result[0].english).toMatch(/water/) done() }) }) it('Should accept where as an object', (done) => { cedict.search({ simplified: '水' }) .then((result) => { expect(result.length).toBe(1) expect(result[0]).toMatchObject({ id: '3f69904700c4fe2fb2caeb3f46501bc66ce245a4', simplified: '水', traditional: '水', pinyin: 'shui3', hskLevel: 1, radicalSimplified: '水', radicalTraditional: '水', strokesSimplified: 4, strokesTraditional: 4, strokesMinRadSimplified: 0, strokesMinRadTraditional: 0, variantsSimplified: null, variantsTraditional: null, variants: '氵' }) expect(result[0].english).toMatch(/water/) done() }) }) }) describe('searchByRadical', () => { it('Should return expected result(s)', (done) => { cedict.searchByRadical('水').then((result) => { expect(result.length > 0).toBe(true) expect('id' in result[0]).toBe(true) expect('simplified' in result[0]).toBe(true) expect('traditional' in result[0]).toBe(true) done() }) }) })