Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(timepicker): added test plan #2127

Merged
merged 1 commit into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions src/spec/timepicker/timepicker-controls.util.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import {
TimeChangeEvent,
TimepickerComponentState,
TimepickerControls
} from '../../timepicker/timepicker.models';

import {
canChangeHours, canChangeMinutes, canChangeSeconds,
canChangeValue, getControlsValue, timepickerControls
} from '../../timepicker/timepicker-controls.util';

function testTime(hours?: number, minutes?: number, seconds?: number) {
let time = new Date();
time.setHours(hours || 0);
time.setMinutes(minutes || 0);
time.setSeconds(seconds || 0);
return time;
}

describe('Runtime coverage. Util: Timepicker-controls', () => {
let state: TimepickerComponentState;
let controls: TimepickerControls;
let event: TimeChangeEvent;

beforeEach(() => {
state = {
min: null,
max: null,
hourStep: 1,
minuteStep: 5,
secondsStep: 10,
readonlyInput: false,
mousewheel: true,
arrowkeys: true,
showSpinners: true,
showMeridian: true,
showSeconds: false,
meridians: ['AM', 'PM']
};

controls = {
canIncrementHours: false,
canIncrementMinutes: false,
canIncrementSeconds: false,
canDecrementHours: false,
canDecrementMinutes: false,
canDecrementSeconds: false
};

event = {
step: 1,
source: ''
};
});

it('should can change value read only', () => {
canChangeValue(state, event);

state.readonlyInput = true;
canChangeValue(state, event);
});

it('should can change value event', () => {
canChangeValue(state);
canChangeValue(state, event);
});

it('should can change value event source and wheel', () => {
event.source = 'wheel';
state.mousewheel = false;

canChangeValue(state, event);
});

it('should can change value event source and key', () => {
event.source = 'key';
state.arrowkeys = false;

canChangeValue(state, event);
});

it('should change Hours', () => {
canChangeHours(event, controls);
});

it('should change Hours no step', () => {
event.step = null;
canChangeHours(event, controls);
});

it('should change Hours step is -1', () => {
event.step = -1;
canChangeHours(event, controls);
});

it('should change Hours can increment', () => {
controls.canIncrementHours = true;
canChangeHours(event, controls);
});

it('should change Minutes', () => {
canChangeMinutes(event, controls);
});

it('should change Minutes no step', () => {
event.step = null;
canChangeMinutes(event, controls);
});

it('should change Minutes step is -1', () => {
event.step = -1;
canChangeMinutes(event, controls);
});

it('should change Minutes can increment', () => {
controls.canIncrementMinutes = true;
canChangeMinutes(event, controls);
});

it('should change Seconds', () => {
canChangeSeconds(event, controls);
});

it('should change Seconds no step', () => {
event.step = null;
canChangeSeconds(event, controls);
});

it('should change Seconds step is -1', () => {
event.step = -1;
canChangeSeconds(event, controls);
});

it('should change Seconds can increment', () => {
controls.canIncrementSeconds = true;
canChangeSeconds(event, controls);
});

it('should get controls value', () => {
getControlsValue(state);
});

it('should set data in timepicker controls', () => {
timepickerControls(new Date(), state);
});

it('should set data in timepicker controls without date', () => {
// unreachable code
});

it('should set data in timepicker controls without showSeconds', () => {
state.showSeconds = true;
timepickerControls(new Date(), state);
});

it('should set data in timepicker controls with max', () => {
state.max = new Date();
timepickerControls(new Date(), state);
});

it('should set data in timepicker controls with max greater to control time', () => {
state.max = testTime(1);
timepickerControls(testTime(), state);
});

it('should set data in timepicker controls with min', () => {
state.min = new Date();
timepickerControls(new Date(), state);
});

it('should set data in timepicker controls with min greater to control time', () => {
state.min = testTime(1);
timepickerControls(testTime(), state);
});
});
Loading