Skip to content

Instantly share code, notes, and snippets.

@agubler
Last active July 5, 2016 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save agubler/cc7941a94703844deea6f14dc4084670 to your computer and use it in GitHub Desktop.
Save agubler/cc7941a94703844deea6f14dc4084670 to your computer and use it in GitHub Desktop.
Compose Aspect Test Case
'base, initialize, and aspect, twice': function() {
let val = 0;
const createBase = compose({})
.mixin({
mixin: {
foo: 0,
doFoo: () => {
val++;
this.foo++;
}
}
});
const createAspectBase = compose({
bar: 'bar'
}, () => {})
.mixin({
mixin: createBase,
aspectAdvice: {
before: {
doFoo() {
val++;
this.foo++;
}
}
}
});
const create = createAspectBase;
const createFooWidget = create
.mixin({
mixin: createAspectBase,
initialize(instance) {
}
})
.extend({
bar: 'baz'
});
// unused factory that aspects
const createExtendedFooWidget = createFooWidget
.mixin({
aspectAdvice: {
before: {
doFoo() {
val++;
this.foo++;
}
}
}
});
const foo = createFooWidget();
foo.doFoo();
assert.strictEqual(foo.foo, 2, 'foo should equal two');
assert.strictEqual(val, 2, 'val should equal two');
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment