UNPKG

lunisolar

Version:

专业农历库,支持公历阴历互转,支持各类黄历数据查询,如八字四柱、阴历、神煞宜忌、时辰吉凶、建除十二神、胎神占方、五行纳音等。支持自定义插件。

51 lines (42 loc) 1.58 kB
import { SolarTerm } from '../../src/class/solarTerm' import { parseDate } from '../../src/utils' describe('test the Term class', () => { it('1901-02-04 立春', () => { expect(SolarTerm.findDate(1901, '立春')).toEqual([1901, 2, 4]) }) it('2022-02-04 立春', () => { expect(SolarTerm.findDate(2022, 2)).toEqual([2022, 2, 4]) }) it('2022-03-20 春分', () => { expect(SolarTerm.findDate(2022, '春分')).toEqual([2022, 3, 20]) }) it('2021-12-21 春分', () => { expect(SolarTerm.findDate(2021, '冬至')).toEqual([2021, 12, 21]) }) }) describe('test Term findNode', () => { it('test', () => { expect(SolarTerm.findNode(parseDate('2022-07-24'), { nodeFlag: 1, returnValue: true })).toEqual( [new SolarTerm('大暑').valueOf(), parseDate('2022-07-23')] ) }) it('test2', () => { expect(SolarTerm.findNode(parseDate('2022-07-24'), { nodeFlag: 0, returnValue: true })).toEqual( [new SolarTerm('小暑').valueOf(), parseDate('2022-07-07')] ) }) it('test3', () => { expect(SolarTerm.findNode(parseDate('2022-1-1'), { nodeFlag: 0, returnValue: true })).toEqual([ new SolarTerm('大雪').valueOf(), parseDate('2021-12-07') ]) expect(SolarTerm.findNode(parseDate('2022-1-1'), { nodeFlag: 1, returnValue: true })).toEqual([ new SolarTerm('冬至').valueOf(), parseDate('2021-12-21') ]) expect(SolarTerm.findNode(parseDate('2022-1-1'), { nodeFlag: 2, returnValue: true })).toEqual([ new SolarTerm('冬至').valueOf(), parseDate('2021-12-21') ]) }) })