diff --git a/package.json b/package.json
index 901401c2..5d84de81 100644
--- a/package.json
+++ b/package.json
@@ -6,10 +6,10 @@
"scripts": {
"test": "npx cross-env TS_NODE_COMPILER_OPTIONS=\"{\"\"allowJs\"\":true}\" npx mocha -r ts-node/register ./test/setup.js ./test/**/*.{js,jsx,ts,tsx}",
"start": "npx webpack-dev-server",
- "prebuild": "npm run lint && npx rimraf dist/*",
+ "prebuild": "npm run test && npm run lint && npx rimraf dist/*",
"build": "npx tsc --declaration",
"publish-npm": "npm run test && npm run build && npm publish",
- "build:example": "npx webpack --production",
+ "build:example": "npm run test && npm run lint && npx webpack --production",
"lint": "npx tslint src/**"
},
"keywords": [
diff --git a/src/pickers/timePicker/MinutePicker.tsx b/src/pickers/timePicker/MinutePicker.tsx
index abb5d732..a48fbe70 100644
--- a/src/pickers/timePicker/MinutePicker.tsx
+++ b/src/pickers/timePicker/MinutePicker.tsx
@@ -109,14 +109,24 @@ class MinutePicker
}
protected getSelectableCellPositions(): number[] {
- return _.range(0, MINUTES_ON_PAGE);
+ const disabled = this.getDisabledPositions();
+ const all = _.range(0, MINUTES_ON_PAGE);
+ if (disabled) {
+ return all.filter((pos) => {
+ return disabled.indexOf(pos) < 0;
+ });
+ }
+
+ return all;
}
protected getInitialDatePosition(): number {
const selectable = this.getSelectableCellPositions();
- if (selectable.indexOf(this.state.date.hour()) < 0) {
+ if (selectable.indexOf(getMinuteCellPosition(this.state.date.minute())) < 0) {
return selectable[0];
}
+
+ return getMinuteCellPosition(this.state.date.minute());
}
protected getDisabledPositions(): number[] {
diff --git a/test/pickers/timePicker/testMinutePicker.js b/test/pickers/timePicker/testMinutePicker.js
index bff98d26..da652184 100644
--- a/test/pickers/timePicker/testMinutePicker.js
+++ b/test/pickers/timePicker/testMinutePicker.js
@@ -139,7 +139,7 @@ describe(': isNextPageAvailable', () => {
const wrapper = mount();
-
+
assert(_.isBoolean(wrapper.instance().isNextPageAvailable()), 'return boolean');
assert.isFalse(wrapper.instance().isNextPageAvailable(), 'return false');
});
@@ -150,7 +150,7 @@ describe(': isNextPageAvailable', () => {
const wrapper = mount();
-
+
assert(_.isBoolean(wrapper.instance().isNextPageAvailable()), 'return boolean');
assert.isTrue(wrapper.instance().isNextPageAvailable(), 'return true');
});
@@ -165,7 +165,7 @@ describe(': isPrevPageAvailable', () => {
const wrapper = mount();
-
+
assert(_.isBoolean(wrapper.instance().isPrevPageAvailable()), 'return boolean');
assert.isFalse(wrapper.instance().isPrevPageAvailable(), 'return false');
});
@@ -176,7 +176,7 @@ describe(': isPrevPageAvailable', () => {
const wrapper = mount();
-
+
assert(_.isBoolean(wrapper.instance().isPrevPageAvailable()), 'return boolean');
assert.isTrue(wrapper.instance().isPrevPageAvailable(), 'return true');
});
@@ -189,7 +189,7 @@ describe(': getCurrentDate', () => {
it('return string in format `MMMM DD, YYYY`', () => {
const wrapper = mount();
-
+
assert(_.isString(wrapper.instance().getCurrentDate()), 'return string');
assert.equal(wrapper.instance().getCurrentDate(), date.format('MMMM DD, YYYY'), 'return proper value');
});
@@ -229,7 +229,7 @@ describe(': switchToNextPage', () => {
it('shift `date` state field one day forward', () => {
const wrapper = mount();
-
+
assert.equal(wrapper.state('date').date(), 12, 'date not changed yet');
wrapper.instance().switchToNextPage();
assert.equal(wrapper.state('date').date(), 12 + 1, 'date shifted one day forward');
@@ -242,9 +242,26 @@ describe(': switchToPrevPage', () => {
it('shift `date` state field one day backward', () => {
const wrapper = mount();
-
+
assert.equal(wrapper.state('date').date(), 12, 'date not changed yet');
wrapper.instance().switchToPrevPage();
assert.equal(wrapper.state('date').date(), 12 - 1, 'date shifted one day backward');
});
-});
\ No newline at end of file
+});
+
+describe(': getSelectableCellPositions', () => {
+ const date = moment('2018-08-12 10:00');
+
+ it('return minutes positions that are >= `minDate`', () => {
+ const wrapper = mount();
+ const expected = [ 3, 4, 5, 6, 7, 8, 9, 10, 11 ];
+ const actual = wrapper.instance().getSelectableCellPositions();
+
+ assert.equal(actual.length, expected.length);
+ expected.forEach((expectPos, i) => {
+ assert.equal(expectPos, actual[i]);
+ });
+ });
+});