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