Skip to content

Instantly share code, notes, and snippets.

@alepez
Created March 21, 2015 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alepez/8f09ab56be99d243c58e to your computer and use it in GitHub Desktop.
Save alepez/8f09ab56be99d243c58e to your computer and use it in GitHub Desktop.
automati javascript test
/*==============================================================================
= Automatic test runner. Add tests below =
==============================================================================*/
$(function () {
/*========== Test runner ==========*/
var Test = function () {
var that = {},
actions = [],
index = -1, elapsedTime = 0;
var runNext = function () {
if (++index < actions.length) {
setTimeout(function () {
elapsedTime += actions[index].t;
console.info('**TEST** time:', elapsedTime, ' step:',index);
actions[index].fn();
runNext();
}, actions[index].t);
}
};
that.next = function (t, fn) {
actions.push({
t: t,
fn: fn
});
return that;
};
that.run = runNext;
return that;
};
/*============================================================================
= Write tests here =
============================================================================*/
var ajaxDelay = parseInt(dtdbg_get('delay'), 10);
/*========== orders ==========*/
console.log('ajaxDelay', ajaxDelay);
var orders = Test()
.next(100 + ajaxDelay, function () {
$('table.headerline td.toggler a.closed').click();
})
.next(100 + ajaxDelay, function () {
$('.payment-info a[href="#edit"]').click();
})
.next(1000, function () {
$('.payment-info a[href="#edit-done"]').click();
})
.next(100, function () {
});
/*========================================
= enable tests here =
========================================*/
orders.run();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment