From 74e09eee1fcc24fab3d9a765626797c3af2fef51 Mon Sep 17 00:00:00 2001 From: Matt Zabriskie Date: Fri, 27 May 2016 11:59:16 -0600 Subject: [PATCH] Adding delay option to wait --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index ebe99cf..713216b 100644 --- a/index.js +++ b/index.js @@ -32,9 +32,10 @@ let mockAdapter = (resolve, reject, config) => { } class Moxios { - constructor() { + constructor(delay = 100) { this.stubs = new Tracker() this.requests = new Tracker() + this.delay = delay } /** @@ -86,9 +87,10 @@ class Moxios { * May need to beef this up a bit in the future. * * @param {Function} fn The function to execute once waiting is over + * @param {Number} delay How much time in milliseconds to wait */ - wait(fn) { - setTimeout(fn) + wait(fn, delay = this.delay) { + setTimeout(fn, delay) } }