-1
我想添加單元測試這一功能:我們如何添加單元測試的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
什麼_better_解決方案?你沒有提供你自己的嘗試。 –