import { testStrictEqualCase } from 'testUtils' ; import ICnChar from 'cnchar-types' ; const testCases = [ { name : '测试spell' , test ( cnchar ) { return [ '测试' . spell ( ) , '测试' . spell ( 'up' ) , '测试' . spell ( 'low' ) , '测试' . spell ( 'first' ) , '测试' . spell ( 'first' , 'low' ) , '测试' . spell ( 'array' ) , '测试' . spell ( 'array' , 'first' , 'low' ) , '测试' . spell ( 'tone' ) , '长大了' . spell ( 'poly' ) , cnchar . spell ( '长大了' , 'poly' , 'tone' ) ] ; } , expect : [ 'CeShi' , 'CESHI' , 'ceshi' , 'CS' , 'cs' , [ 'Ce' , 'Shi' ] , [ 'c' , 's' ] , 'CèShì' , '(Zhang|Chang)(Da|Dai)(Le|Liao)' , '(Zhǎng|Cháng)(Dà|Dài)(Le|Liǎo)' ] } , { name : '测试 spellToWord' , test ( cnchar ) { return [ cnchar . spellToWord ( 'shàng' ) , cnchar . spellToWord ( 'shàng' , 'alltone' ) , cnchar . spellToWord ( 'shang4' , 'alltone' ) , cnchar . spellToWord ( 'lv2' ) ] ; } , expect : [ '上尚绱' , '上伤汤尚垧殇晌商绱觞赏墒熵裳' , '上伤汤尚垧殇晌商绱觞赏墒熵裳' , '驴闾榈' , ] } , { name : '测试 spellInfo' , test ( cnchar ) { return [ cnchar . spellInfo ( 'Shàng' ) , cnchar . spellInfo . initials . join ( '' ) , cnchar . spellInfo . tones . join ( '' ) ] ; } , expect : [ { spell : 'shang' , tone : 4 , index : 3 , initial : 'sh' , final : 'ang' } , 'bpmfdtnlgkhjqxzhchshrzcsyw' , 'āáǎàōóǒòēéěèīíǐìūúǔùǖǘǚǜ*ńňǹ' ] } , { name : '测试 setSpell' , test ( cnchar ) { cnchar . setSpell ( '你' , 'ni' ) ; cnchar . setSpell ( '我' , [ 'wo1' , 'ha4' ] ) ; cnchar . setSpell ( { '他' : 'ta4' , '它' : [ 'ta2' , 'ha3' ] } ) ; return [ cnchar . spell ( '你' , 'tone' , 'poly' ) , cnchar . spell ( '我' , 'tone' , 'poly' ) , cnchar . spell ( '他' , 'tone' , 'poly' ) , cnchar . spell ( '它' , 'tone' , 'poly' ) , cnchar . isPolyWord ( '你' ) ] ; } , expect : [ '(Nǐ|Ni)' , '(Wǒ|Wō|Hà)' , '(Tā|Tà)' , '(Tā|Tá|Hǎ)' , true ] } , ] ; testStrictEqualCase ( { testCases } ) ;