Skip to content

Commit

Permalink
Changed coordinates from objects to array for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed May 24, 2013
1 parent 8c2aa96 commit e92a1a5
Showing 1 changed file with 20 additions and 62 deletions.
82 changes: 20 additions & 62 deletions test/drift.js
Expand Up @@ -40,8 +40,8 @@ function testDrift (test, direction) {
var startCoordinates = {}; var startCoordinates = {};
if (test.hasOwnProperty('startCoordinates')) { if (test.hasOwnProperty('startCoordinates')) {
startCoordinates = { startCoordinates = {
x: test.startCoordinates.x, x: test.startCoordinates[0],
y: test.startCoordinates.y y: test.startCoordinates[1]
}; };
} else { } else {
startCoordinates = { startCoordinates = {
Expand Down Expand Up @@ -73,11 +73,11 @@ function testDrift (test, direction) {
return result; return result;
}, function () { }, function () {
var pre = distance + ' px, ' + degree + 'º, ' + duration + ' ms'; var pre = distance + ' px, ' + degree + 'º, ' + duration + ' ms';
that.test.assertEquals(that.getScrollLeft(), target.direct.x, pre + ' direct after drift - x'); that.test.assertEquals(that.getScrollLeft(), target.direct[0], pre + ' direct after drift - x');
that.test.assertEquals(that.getScrollTop(), target.direct.y, pre + ' direct after drift - y'); that.test.assertEquals(that.getScrollTop(), target.direct[1], pre + ' direct after drift - y');
casper.wait(1000, function () { casper.wait(1000, function () {
that.test.assertEquals(that.getScrollLeft(), target.delay.x, pre + ' 1 sec after drift - x'); that.test.assertEquals(that.getScrollLeft(), target.delay[0], pre + ' 1 sec after drift - x');
that.test.assertEquals(that.getScrollTop(), target.delay.y, pre + ' 1 sec after drift - y'); that.test.assertEquals(that.getScrollTop(), target.delay[1], pre + ' 1 sec after drift - y');
}); });
}); });


Expand All @@ -88,40 +88,22 @@ function testDrift (test, direction) {
var driftUp = [ var driftUp = [
{ {
target: { target: {
direct: { direct: [0, 81],
x: 0, delay: [0, 110]
y: 81
},
delay: {
x: 0,
y: 110
}
}, },
distance: 50 distance: 50
}, },
{ {
target: { target: {
direct: { direct: [0, 165],
x: 0, delay: [0, 236]
y: 165
},
delay: {
x: 0,
y: 236
}
}, },
distance: 100 distance: 100
}, },
{ {
target: { target: {
direct: { direct: [0, 247],
x: 0, delay: [0, 363]
y: 247
},
delay: {
x: 0,
y: 363
}
}, },
distance: 150 distance: 150
} }
Expand All @@ -130,10 +112,7 @@ var driftUp = [
driftUp.forEach(function (test) { driftUp.forEach(function (test) {
// same options for all tests // same options for all tests
// don't need to be repeated! // don't need to be repeated!
test.startCoordinates = { test.startCoordinates = [20, 400];
x: 20,
y: 400
};
test.duration = 0.02; test.duration = 0.02;
test.degree = 0; test.degree = 0;


Expand All @@ -143,50 +122,29 @@ driftUp.forEach(function (test) {
var driftLeft = [ var driftLeft = [
{ {
target: { target: {
direct: { direct: [81, 0],
x: 81, delay: [110, 0]
y: 0
},
delay: {
x: 110,
y: 0
}
}, },
distance: 50 distance: 50
}, },
{ {
target: { target: {
direct: { direct: [165, 0],
x: 165, delay: [236, 0]
y: 0
},
delay: {
x: 236,
y: 0
}
}, },
distance: 100 distance: 100
}, },
{ {
target: { target: {
direct: { direct: [247, 0],
x: 247, delay: [363, 0]
y: 0
},
delay: {
x: 363,
y: 0
}
}, },
distance: 150 distance: 150
} }
]; ];


driftLeft.forEach(function (test) { driftLeft.forEach(function (test) {
test.startCoordinates = { test.startCoordinates = [400, 20];
x: 400,
y: 20
};
test.duration = 0.02; test.duration = 0.02;
test.degree = 270; test.degree = 270;


Expand Down

0 comments on commit e92a1a5

Please sign in to comment.