Rewrote Jasmine tests for slider range to reuse function. More compact and concise.
This commit is contained in:
@@ -185,75 +185,59 @@
|
||||
});
|
||||
|
||||
describe('checking start and end times', function () {
|
||||
var miniTestSuite = [
|
||||
{
|
||||
itDescription: 'both times are proper',
|
||||
data: {start: 12, end: 24},
|
||||
expectData: {start: 12, end: 24}
|
||||
},
|
||||
{
|
||||
itDescription: 'start time is invalid',
|
||||
data: {start: '', end: 24},
|
||||
expectData: {start: 0, end: 24}
|
||||
},
|
||||
{
|
||||
itDescription: 'end time is invalid',
|
||||
data: {start: 12, end: ''},
|
||||
expectData: {start: 12, end: null}
|
||||
},
|
||||
{
|
||||
itDescription: 'start time is less than 0',
|
||||
data: {start: -12, end: 24},
|
||||
expectData: {start: 0, end: 24}
|
||||
},
|
||||
{
|
||||
itDescription: 'start time is greater than end time',
|
||||
data: {start: 42, end: 24},
|
||||
expectData: {start: 42, end: null}
|
||||
},
|
||||
];
|
||||
|
||||
beforeEach(function () {
|
||||
loadFixtures('video.html');
|
||||
|
||||
});
|
||||
|
||||
it('both times are proper', function () {
|
||||
$('#example').find('.video')
|
||||
.data({
|
||||
'start': 12,
|
||||
'end': 24
|
||||
});
|
||||
|
||||
state = new Video('#example');
|
||||
|
||||
expect(state.config.start).toBe(12);
|
||||
expect(state.config.end).toBe(24);
|
||||
$.each(miniTestSuite, function (index, test) {
|
||||
itFabrique(test.itDescription, test.data, test.expectData);
|
||||
});
|
||||
|
||||
it('start time is invalid', function () {
|
||||
$('#example').find('.video')
|
||||
.data({
|
||||
'start': '',
|
||||
'end': 24
|
||||
});
|
||||
return;
|
||||
|
||||
state = new Video('#example');
|
||||
function itFabrique(itDescription, data, expectData) {
|
||||
it(itDescription, function () {
|
||||
$('#example').find('.video')
|
||||
.data({
|
||||
'start': data.start,
|
||||
'end': data.end
|
||||
});
|
||||
|
||||
expect(state.config.start).toBe(0);
|
||||
expect(state.config.end).toBe(24);
|
||||
});
|
||||
state = new Video('#example');
|
||||
|
||||
it('end time is invalid', function () {
|
||||
$('#example').find('.video')
|
||||
.data({
|
||||
'start': 12,
|
||||
'end': ''
|
||||
});
|
||||
|
||||
state = new Video('#example');
|
||||
|
||||
expect(state.config.start).toBe(12);
|
||||
expect(state.config.end).toBe(null);
|
||||
});
|
||||
|
||||
it('start time is less than 0', function () {
|
||||
$('#example').find('.video')
|
||||
.data({
|
||||
'start': -12,
|
||||
'end': 24
|
||||
});
|
||||
|
||||
state = new Video('#example');
|
||||
|
||||
expect(state.config.start).toBe(0);
|
||||
expect(state.config.end).toBe(24);
|
||||
});
|
||||
|
||||
it('start time is greater than end time', function () {
|
||||
$('#example').find('.video')
|
||||
.data({
|
||||
'start': 42,
|
||||
'end': 24
|
||||
});
|
||||
|
||||
state = new Video('#example');
|
||||
|
||||
expect(state.config.start).toBe(42);
|
||||
expect(state.config.end).toBe(null);
|
||||
});
|
||||
expect(state.config.start).toBe(expectData.start);
|
||||
expect(state.config.end).toBe(expectData.end);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('multiple YT on page', function () {
|
||||
|
||||
Reference in New Issue
Block a user