1
0
Fork 0

Updated tests for hooks workaround

This commit is contained in:
Joost De Cock 2018-09-30 16:56:02 +02:00
parent 0963a4f330
commit a0a316b60e

View file

@ -42,16 +42,12 @@ let count = 0;
let pre = function() { let pre = function() {
count += 5; count += 5;
}; };
let post = function() {
count = count * -1;
};
it("Should attach the preDraft & postDraft hooks", () => { it("Should attach the preDraft & postDraft hooks", () => {
count = 0; count = 0;
let obj = { let obj = {
draft: function() {}, draft: function() {},
pre: pre, pre: pre
post: post
}; };
h._hooks = { h._hooks = {
preDraft: [ preDraft: [
@ -70,15 +66,14 @@ it("Should attach the preDraft & postDraft hooks", () => {
expect(count).to.equal(5); expect(count).to.equal(5);
expect(h.attach("postDraft", obj)).to.equal(undefined); expect(h.attach("postDraft", obj)).to.equal(undefined);
obj.draft(); obj.draft();
expect(count).to.equal(-5); expect(count).to.equal(10);
}); });
it("Should attach the preSample & postSample hooks", () => { it("Should attach the preSample & postSample hooks", () => {
count = 0; count = 0;
let obj = { let obj = {
sampleOption: function() {}, sampleOption: function() {},
pre: pre, pre: pre
post: post
}; };
h._hooks = { h._hooks = {
preSample: [ preSample: [
@ -94,18 +89,17 @@ it("Should attach the preSample & postSample hooks", () => {
}; };
expect(h.attach("preSample", obj)).to.equal(undefined); expect(h.attach("preSample", obj)).to.equal(undefined);
obj.sampleOption(); obj.sampleOption();
expect(count).to.equal(15); expect(count).to.equal(5);
expect(h.attach("postSample", obj)).to.equal(undefined); expect(h.attach("postSample", obj)).to.equal(undefined);
obj.sampleOption(); obj.sampleOption();
expect(count).to.equal(-15); expect(count).to.equal(10);
}); });
it("Should attach the debug hook", () => { it("Should attach the debug hook", () => {
count = 0; count = 0;
let obj = { let obj = {
debug: function() {}, debug: function() {},
pre: pre, pre: pre
post: post
}; };
h._hooks = { h._hooks = {
debug: [ debug: [