Created
May 20, 2015 23:20
-
-
Save Twipped/d8d3448d3e50b62f7e86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeSequence(test, closures) { | |
return function () { | |
if (!closures.length) { | |
test.ok(false, 'Sequence was invoked too many times.'); | |
throw new Error('Sequence was invoked too many times.'); | |
} | |
test.ok(true, 'Sequence stepped'); | |
return closures.shift().apply(this, arguments); | |
}; | |
} | |
var mocksql = { | |
query: makeSequence(test, [ | |
function (query, data, cb) { | |
test.equal(query, 'REPLACE INTO `orders_labeled` SET orderid = ?, labelid = ?'); | |
test.deepEqual(data, [123, 2]); | |
cb(); | |
}, | |
function (query, data, cb) { | |
test.equal(query, 'DELETE FROM `orders_labeled` WHERE (orderid = ? AND labelid = ?)'); | |
test.deepEqual(data, [123, 3]); | |
cb(); | |
} | |
]) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment