Skip to content

Commit

Permalink
release v3.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
xupaopaopaopao committed May 2, 2017
1 parent 1f59f69 commit 1107fa5
Show file tree
Hide file tree
Showing 71 changed files with 373 additions and 208 deletions.
15 changes: 15 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## v3.0.9 (2017-05-02)

### New Features
- `Calendar` 添加 `allowSelectionBeforeToday` 属性,允许用户选择当前日期之前的时间段。
- `Picker` 添加 `itemHeight` 属性,用来设置 item 高度。

### Bug Fixes
- 修复 `Scroller` 在调用 `scrollTo` 方法时,吸顶容器没有被正确刷新的 bug。
- 修复 `Scroller` 在回弹过程中点击页面导致无法回弹到正确位置的 bug。
- 修复 `LazyImage` 在更新之后获取位置不正确导致图片无法加载的 bug。
- 修复 `Calendar``duration` 的起始日期大于当前日期时,可选择区域不准确的 bug。
- 修复 `Calendar``duration` 属性改变时,起始日期所在的周未及时更新的 bug。
- 修复 `Calendar``onChange` 触发时,输出的格式不规范的 bug,将 YYYY-MM-(D)D 格式改成 YYYY-MM-DD 格式。
- 修复 `Carousel` 当 触发 `toucheEnd` 事件时没有生成对应 `touch` 对象情况下, 没有重置定时器的 bug。

## v3.0.8 (2017-04-07)

### New Features
Expand Down
70 changes: 59 additions & 11 deletions component_dev/calendar/__tests__/calendar.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Component } from 'react';
import { mount } from 'enzyme';
import injectTapEventPlugin from 'react-tap-event-plugin';
import CalendarCore from '../src/CalendarCore';
Expand All @@ -13,7 +13,6 @@ const formatDate = time => {
};

const calendarCore = new CalendarCore();
// custom在前面,要不getGroupKey test会出错
const customHolidayData = calendarCore.getData({
duration: ['2017-10-1', '2018-4-30']
});
Expand Down Expand Up @@ -42,18 +41,17 @@ test('the number of day besides today which can be selected is 181, and all Chec
num++;
j % 6 === 0 ? expect(weekend).toBeTruthy() : expect(weekend).toBeFalsy();
}

expect(isCheckIn).toBeFalsy();
expect(isCheck).toBeFalsy();
expect(isCheckOut).toBeFalsy();
expect(day || 0).toBeLessThanOrEqual(31);
});
});
expect(num).toBe(181);
});

test('the groupKey of no selectonStart is today', () => {
expect(calendarCore.getGroupKey()).toBe(`${toDayYear}${toDayMonth}月`);
const allDateItem = testWrap.find('ul.week li');
const disableDateLenght = allDateItem.filter('.disabled').length;
expect(allDateItem.length - disableDateLenght).toBe(181);
});

test('the today node must has today class', () => {
Expand Down Expand Up @@ -117,10 +115,6 @@ const customWrap = mount(<Calendar
selectionEndText="gogogo"
/>);

test('the groupKey should be the group where the selectionStart located', () => {
expect(customCore.getGroupKey()).toBe(`${selectionStartYear}${selectionStartMonth}月`);
});

test('the Check property should be true between selectionStart and selectionEnd, the custom text should be setted', () => {
let num = 0;
customData.forEach(item => {
Expand Down Expand Up @@ -160,4 +154,58 @@ const renderDateWrap = mount(<Calendar renderDate={renderDate} />);
test('only today will be used the customed renderDate', () => {
expect(renderDateWrap.find('li.today').children().html()).toBe('<span class="custom-today-class">我不管,今天必须实现成这种模式</span>');
expect(renderDateWrap.find('.custom-today-class')).toHaveLength(1);
});

const testCore = new CalendarCore();
const futureData = testCore.getData({duration: [selectionStart, selectionEnd]});
const futureWrap = mount(<Calendar duration={[selectionStart, selectionEnd]} />)
test('the future duration which can be selected is 7', () => {
let num = 0;
futureData.forEach(item => {
item.week.forEach(dayItem => {
if (!dayItem.disabled) num++;
});
});
const allDateItem = futureWrap.find('ul.week li');
const disableDateLenght = allDateItem.filter('.disabled').length;
expect(allDateItem.length - disableDateLenght).toBe(7);
expect(num).toBe(7);
});

const selectionBeforeTodayData = testCore.getData({ duration: ['2017-01-10', '2017-01-20' ], allowSelectionBeforeToday: true });
const selectionBeforeTodayWrap = mount(<Calendar duration={['2017-01-10', '2017-01-20' ]} allowSelectionBeforeToday />)
test('the allowSelectionBeforeToday is true, the range of selection is only depend on the duration property', () => {
let num = 0;
selectionBeforeTodayData.forEach(item => {
item.week.forEach(dayItem => {
if (!dayItem.disabled) num++;
});
});
const allDateItem = selectionBeforeTodayWrap.find('ul.week li');
const disableDateLenght = allDateItem.filter('.disabled').length;
expect(allDateItem.length - disableDateLenght).toBe(11);
expect(num).toBe(11);
});

class ChangeDuration extends Component {
state = {
duration: ['2017-2-10', '2017-3-10'],
};

render() {
return (
<Calendar duration={this.state.duration} allowSelectionBeforeToday />
);
}
}

const changeDurationWrap = mount(<ChangeDuration />);
test('the date which can be selected should correct when the duration property changed', () => {
const allDateItem = changeDurationWrap.find('ul.week li');
const disableDateLenght = allDateItem.filter('.disabled').length;
expect(allDateItem.length - disableDateLenght).toBe(29);
changeDurationWrap.setState({duration: ['2017-1-10', '2017-4-10']});
const allDateItem2 = changeDurationWrap.find('ul.week li');
const disableDateLenght2 = allDateItem2.filter('.disabled').length;
expect(allDateItem2.length - disableDateLenght2).toBe(91);
});
Loading

0 comments on commit 1107fa5

Please sign in to comment.