1
私はjasmine-karmaを使い慣れました。以下のシナリオをどのように実行するかを把握しようとしています。ジャスミンのフィルターオブジェクトと返り値
これは細かい
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
}));
});
});