assert.notPropContains()
追加のバージョン: 2.18.0.
説明
notPropContains(actual, expected, message = "")
オブジェクトに特定のプロパティが含まれていないことを確認します。
名前 | 説明 |
---|---|
実際 |
テスト中の表現 |
期待 |
既知の比較値 |
メッセージ (文字列) |
簡単な説明 |
notPropContains
アサーションは、期待するオブジェクトのプロパティのサブセットを比較し、これらのキーが存在しないか、厳密な等価比較に従って異なる値を持っているかどうかをテストします。
このメソッドは再帰的で、入れ子になったオブジェクトの部分的な比較も許可します。
関連項目
- その代わりに、
assert.propContains()
を使用して、プロパティの存在と等価性をテストします。
例
QUnit.test('example', assert => {
const result = {
foo: 0,
vehicle: {
timeCircuits: 'on',
fluxCapacitor: 'fluxing',
engine: 'running'
},
quux: 1
};
// succeeds, property "timeCircuits" is actually "on"
assert.notPropContains(result, {
vehicle: {
timeCircuits: 'off'
}
});
// succeeds, property "wings" is not in the object
assert.notPropContains(result, {
vehicle: {
wings: 'flapping'
}
});
function Point (x, y) {
this.x = x;
this.y = y;
}
assert.notPropContains(
new Point(10, 20),
{ z: 30 }
);
const nested = {
north: [ /* ... */ ],
east: new Point(10, 20),
south: [ /* ... */ ],
west: [ /* ... */ ]
};
assert.notPropContains(nested, { east: new Point(88, 42) });
assert.notPropContains(nested, { east: { x: 88 } });
});