Commit d16cecaf authored by Jarrod's avatar Jarrod 💬

Cast input of byIndex to int

parent 647def2d
Pipeline #1311 passed with stage
in 20 seconds
......@@ -7,6 +7,7 @@ class Rad {
}
static byIndex (idx) {
idx = parseInt(idx)
return radicals.filter(r => r.no === idx).shift()
}
......
{
"name": "@nahanil/bushou",
"version": "0.0.2",
"version": "0.0.3",
"description": "Work with Chinese radicals",
"main": "lib/index.js",
"directories": {
......@@ -23,4 +23,3 @@
"standard": "^12.0.1"
}
}
......@@ -18,6 +18,17 @@ describe('byIndex()', () => {
expect(radical.english).toBe('water')
expect(radical.strokes).toBe(4)
})
it ('should return a radical by kangxi index', () => {
let radical = rad.byIndex('85')
expect(radical.no).toBe(85)
expect(radical.simplified).toBe('')
expect(radical.radical).toBe('水')
expect(radical.variants).toBe('氵')
expect(radical.pinyin).toBe('shui3')
expect(radical.english).toBe('water')
expect(radical.strokes).toBe(4)
})
})
describe('for()', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment