Created
December 6, 2017 23:26
-
-
Save k1r0s/4e129087e924cbbbf4fce1fed748639a to your computer and use it in GitHub Desktop.
merge some async advices showcase
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
import { beforeMethod } from ".."; | |
const Delay = secs => meta => setTimeout(meta.commit, secs); | |
const soMuchDelay = [Delay(1000), Delay(1000), Delay(1000)]; | |
const someBehavior = beforeMethod(...soMuchDelay, Delay(5)); | |
class Car { | |
@someBehavior | |
startEngine(cbk){ | |
cbk(); | |
} | |
} | |
let carInstance; | |
describe("advance reflect.advice specs", () => { | |
beforeEach(() => { | |
carInstance = new Car; | |
}) | |
it("Delay advice should stop the execution for a while", done => { | |
const time = Date.now(); | |
carInstance.startEngine(function() { | |
expect(Date.now() - time).toBeGreaterThan(3000); | |
expect(Date.now() - time).toBeLessThan(3100); | |
done(); | |
}); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment