のユニットテストを追加するにはどうすればよい私は、この機能のためのユニットテストを追加しようとしています:は、我々はJavascript hasOwnPropertyを()関数
var advance = function (des, source) {
for (var p in source) {
if (source.hasOwnProperty(p)) {
des[p] = source[p];
}
}
return des;
};
はどのように我々はジャスミンでhasOwnProperty()
方法をチェックしますか?
編集: 解決策
var des;
var source;
beforeEach(function() {
des = {};
source = {
p: 'value',
p1: 'value1'
};
});
beforeAll(function() {
advance(des, source);
});
it('should has a property with the name of the argument', function() {
expect(source).toEqual(jasmine.objectContaining({
p: 'value'
}));
expect(source).not.toEqual(jasmine.objectContaining({
p2: 'value2'
}));
});
誰かは、任意のより良い解決策を提案してください。
もっと良い解決策は何ですか?あなたの現在のユニットテストは何ですか? –
そして、十字タグ付けをしないでください。 Java!= JavaScript! – GhostCat
何が解決策ですか?あなたは自分の試みを提供しませんでした。 –