我有这样的一种:
enyo.kind({
name:"branding", components: [
{name: "appName", content:"Stars of the East", classes:"heading"},
{content:AppConfig.tagline, classes:"subHeading"}]
});我正在尝试用下面的茉莉花describe来测试这种类型。
describe("Test Branding Kind", function() {
it("should see enyo component from jasmine", function() {
var branding = enyo.kind({
kind: "branding"
});
expect(branding.$.appName.getContent()).toBe("Stars of the East");
})
});我搞错了。有人能指引我吗?
发布于 2014-12-10 23:29:55
你需要实例化你的同类来测试它。enyo.kind()只创建模板。尝试:
describe("Test Branding Kind", function() {
it("should see enyo component from jasmine", function() {
var localBranding = new branding();
expect(localBranding.$.appName.getContent()).toBe("Stars of the East");
})
});您还必须修复Art指出的没有components块的问题。
如果组件具有要检查的UI元素,则可能还需要实际呈现组件。您可能希望将localBranding行更改为:
var localBranding = new branding().renderInto(<some element on your page>);最后,我们建议用大写字母来区分它们和实例名称。如果你听从我们的建议,name: "branding"就是name: "Branding"。
发布于 2014-12-10 18:52:29
您需要将您的子组件放在一个组件数组中(您的代码中已经有了该数组的结束括号):
enyo.kind({
name:"branding", components: [
{name: "appName", content:"Stars of the East", classes:"heading"},
{content:AppConfig.tagline, classes:"subHeading"}]
});https://stackoverflow.com/questions/27397296
复制相似问题