project/node_modules/lunar-calendar/test/index.js

29 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 测试用例
var expect = require('expect.js'),
LunarCalendar = require('../lib/LunarCalendar');
describe('lunar-calendar', function(){
var solarDate = new Date(2014, 1, 1); //公历2014年2月1日
var lunarDate = {
"zodiac": "蛇", //生肖属相
"GanZhiYear": "癸巳", //干支纪年
"GanZhiMonth": "乙丑", //干支纪月
"GanZhiDay": "癸卯", //干支纪日
"worktime": 2, //0无特殊安排1工作2放假
"lunarYear": 2014, //农历年
"lunarMonth": 1, //农历月1-13有闰月情况比如当前闰9月10表示闰9月11表示10月
"lunarDay": 2, //农历日
"lunarMonthName": "正月", //农历月中文名
"lunarDayName": "初二", //农历日中文名
"lunarLeapMonth": 9, //农历闰月所在月份0表示无闰月
"solarFestival": undefined, //公历节假日undefined或劳动节之类
"lunarFestival": undefined, //农历节假日undefined或除夕之类
"term": undefined //二十四节气名undefined或立春之类
};
it('.solarToLunar(year,month,day),公历转农历', function(){
var lunar = LunarCalendar.solarToLunar(solarDate.getFullYear(),solarDate.getMonth()+1,solarDate.getDate());
expect(lunar).to.eql(lunarDate);
});
});