#937 front test datePicker
This commit is contained in:
parent
9063077e30
commit
992be9ecfb
|
@ -29,24 +29,13 @@ class DatePicker extends Component {
|
|||
if (this.vp.selectedDates.length) {
|
||||
let date = this.vp.selectedDates[0];
|
||||
|
||||
if (!this.isLocale && !this._iniOptions.enableTime && !this.iniOptions.onlyDate) {
|
||||
let now = new Date();
|
||||
date.setTime(date.getTime()
|
||||
+ now.getHours() * 60 * 60 * 1000
|
||||
+ now.getUTCMinutes() * 60 * 1000
|
||||
+ now.getUTCSeconds() * 1000
|
||||
+ now.getUTCMilliseconds()
|
||||
);
|
||||
}
|
||||
console.log(this.iniOptions);
|
||||
if (this.iniOptions.onlyDate) {
|
||||
if (!this.isLocale && !this._iniOptions.enableTime) {
|
||||
let now = new Date();
|
||||
|
||||
let offset = now.getTimezoneOffset() * 60000;
|
||||
date.setHours(0, 0, 0, 0);
|
||||
date.setTime(date.getTime() - offset);
|
||||
}
|
||||
console.log(date);
|
||||
this._model = date;
|
||||
} else
|
||||
this.model = null;
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
// #937 front test datePicker awaiting loopback connector refactor to store dates correctly.
|
||||
xdescribe('Component vnDatePicker', () => {
|
||||
let controller;
|
||||
let $attrs;
|
||||
let $element;
|
||||
let today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
beforeEach(ngModule('vnCore'));
|
||||
|
||||
beforeEach(angular.mock.inject($componentController => {
|
||||
$attrs = {};
|
||||
$translate = {use: () => {
|
||||
return 'es';
|
||||
}};
|
||||
$element = angular.element(`<vn-date-picker><div><input type="text" class="mdl-textfield__input" name="MyName" ng-disabled="$ctrl.disabled" rule=""></input></div></vn-date-picker>`);
|
||||
controller = $componentController('vnDatePicker', {$element, $attrs, $translate});
|
||||
}));
|
||||
|
||||
describe('onValueUpdate() while date is selected', () => {
|
||||
it(`should store the selected date in the controller`, () => {
|
||||
controller.vp = {selectedDates: [today]};
|
||||
controller.isLocale = true;
|
||||
controller.onValueUpdate();
|
||||
|
||||
expect(controller._model).toEqual(today);
|
||||
});
|
||||
|
||||
it(`should format the date`, () => {
|
||||
controller.vp = {selectedDates: [today], destroy: () => {}};
|
||||
controller.isLocale = undefined;
|
||||
controller._iniOptions.enableTime = undefined;
|
||||
|
||||
controller.onValueUpdate();
|
||||
|
||||
expect(controller._model).toEqual(today);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue