mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
66 lines
1.1 KiB
JavaScript
66 lines
1.1 KiB
JavaScript
var expect = require("chai").expect;
|
|
var lookup = require("./lookup");
|
|
|
|
var items = [
|
|
{
|
|
id: 0,
|
|
title: "Item 1",
|
|
},
|
|
{
|
|
id: 1,
|
|
title: "Item 2",
|
|
},
|
|
{
|
|
id: 2,
|
|
title: "Item 3",
|
|
},
|
|
];
|
|
|
|
module.exports = function (helpers) {
|
|
var component = helpers.mount(require.resolve("./index"), {
|
|
items: items,
|
|
});
|
|
|
|
// Test first one twice, should be the same
|
|
lookup.componentsById[0].emitPurchase();
|
|
expect(component.purchaseEvents).to.deep.equal([
|
|
{
|
|
id: 0,
|
|
title: "Item 1",
|
|
},
|
|
]);
|
|
|
|
lookup.componentsById[0].emitPurchase();
|
|
expect(component.purchaseEvents).to.deep.equal([
|
|
{
|
|
id: 0,
|
|
title: "Item 1",
|
|
},
|
|
]);
|
|
|
|
// Test second one twice, should be the same
|
|
lookup.componentsById[1].emitPurchase();
|
|
expect(component.purchaseEvents).to.deep.equal([
|
|
{
|
|
id: 0,
|
|
title: "Item 1",
|
|
},
|
|
{
|
|
id: 1,
|
|
title: "Item 2",
|
|
},
|
|
]);
|
|
|
|
lookup.componentsById[1].emitPurchase();
|
|
expect(component.purchaseEvents).to.deep.equal([
|
|
{
|
|
id: 0,
|
|
title: "Item 1",
|
|
},
|
|
{
|
|
id: 1,
|
|
title: "Item 2",
|
|
},
|
|
]);
|
|
};
|