UNPKG

tyme4ts

Version:

Tyme是一个非常强大的日历工具库,可以看作 Lunar 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。

45 lines (37 loc) 1.22 kB
import {suite, test} from '@testdeck/mocha'; import {EarthBranch} from '../lib'; import {equal, ifError} from 'assert'; @suite class EarthlyBranchTest { @test test() { equal(EarthBranch.fromIndex(0).getName(), '子'); } @test test1() { equal(EarthBranch.fromIndex(0).getIndex(), 0); } @test test2() { equal(EarthBranch.fromName('子').getOpposite().getName(), '午'); equal(EarthBranch.fromName('戌').getOpposite().getName(), '辰'); } @test test3() { equal(EarthBranch.fromName('子').getCombine().getName(), '丑'); equal(EarthBranch.fromName('申').getCombine().getName(), '巳'); } @test test4() { equal(EarthBranch.fromName('巳').getHarm().getName(), '寅'); equal(EarthBranch.fromName('申').getHarm().getName(), '亥'); } @test test5() { // 合化 equal(EarthBranch.fromName('卯').combine(EarthBranch.fromName('戌'))!.getName(), '火'); equal(EarthBranch.fromName('戌').combine(EarthBranch.fromName('卯'))!.getName(), '火'); // 卯子无法合化 ifError(EarthBranch.fromName('卯').combine(EarthBranch.fromName('子'))); } }