Skip to content

Instantly share code, notes, and snippets.

@k1r0s
Created December 6, 2017 23:26
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 k1r0s/4e129087e924cbbbf4fce1fed748639a to your computer and use it in GitHub Desktop.
Save k1r0s/4e129087e924cbbbf4fce1fed748639a to your computer and use it in GitHub Desktop.
merge some async advices showcase
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