1
我是茉莉花 - 卡瑪。所以試圖找出如何執行下面的情況。篩選對象並返回茉莉花計數
這工作得很好
describe("jasmine.objectContaining", function() {
var foo;
beforeEach(function() {
foo = {
a: 1,
b: 2,
bar: "baz"
};
});
it("matches objects with the expect key/value pairs", function() {
expect(foo).toEqual(jasmine.objectContaining({
bar: "baz"
}));
});
});
但現在如果我改變物體對象的數組這是行不通的。 那麼,如何從對象數組中過濾並返回計數。
例如。
describe("jasmine.objectContaining", function() {
var foo;
beforeEach(function() {
foo = [{
a: 1,
b: 2,
bar: "baz"
},
{
a: 1,
b: 2,
bar: "bdd"
}
];
});
it("matches objects with the expect key/value pairs", function() {
expect(foo).//find object(s) containing bar:"baz" and it should return count=1
}));
});
});