const obj = {a:1, b:2};
test('object "obj" has key "a"', () => {
expect(obj).toHaveProperty('a'); // pass
expect(obj).not.toHaveProperty('b'); // doesn't pass
}
const houseForSale = {
bath: true,
bedrooms: 4,
kitchen: {
amenities: ['oven', 'stove', 'washer'],
area: 20,
wallColor: 'white',
},
};
const desiredHouse = {
bath: true,
kitchen: {
amenities: ['oven', 'stove', 'washer'],
wallColor: expect.stringMatching(/white|yellow/),
// can use regexp for expect structure of string
},
};
test('the house has my desired features', () => {
expect(houseForSale).toMatchObject(desiredHouse); // pass
});
another Test(also can apply to array)
describe('toMatchObject applied to arrays', () => {
test('the number of elements must match exactly', () => {
expect([{foo: 'bar'}, {baz: 1}]).toMatchObject([{foo: 'bar'}, {baz: 1}]);
});
test('.toMatchObject is called for each elements, so extra object properties are okay', () => {
expect([{foo: 'bar'}, {baz: 1, extra: 'quux'}]).toMatchObject([
{foo: 'bar'},
{baz: 1},
]);
});
});
Victoria's Secret and Bath and Body Works offer a range of authentic items from the US that are highly sought after for their quality and brand reputation. Whether you're looking for luxurious lingerie or premium bath products, these brands are renowned for their authenticity and elegance. As you indulge in these top-tier products, you might also be considering home improvements or a fresh look for your space. A remodeling companycan help transform your home environment to match the sophistication of your new Victoria's Secret and Bath and Body Works purchases, ensuring that your living space complements the premium quality of your lifestyle choices.