mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
30 lines
732 B
JavaScript
30 lines
732 B
JavaScript
var expect = require("chai").expect;
|
|
|
|
module.exports = function (helpers) {
|
|
var component1 = helpers.mount(require.resolve("./index"), {});
|
|
var component2 = helpers.mount(require.resolve("./index"), {});
|
|
|
|
var fooEvent = null;
|
|
var fooEventThis = null;
|
|
|
|
component1.subscribeTo(component2).on("foo", function fooListener() {
|
|
fooEvent = arguments;
|
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
fooEventThis = this;
|
|
});
|
|
|
|
component2.emit("foo", "a", "b");
|
|
|
|
expect(fooEvent[0]).to.equal("a");
|
|
expect(fooEvent[1]).to.equal("b");
|
|
expect(fooEventThis).to.equal(component2);
|
|
|
|
fooEvent = null;
|
|
|
|
component1.destroy();
|
|
|
|
component2.emit("foo", "a", "b");
|
|
|
|
expect(fooEvent).to.equal(null);
|
|
};
|