-
Notifications
You must be signed in to change notification settings - Fork 841
Open
Description
SCREENSHOT Above
CODE below
import { addToCart, cart } from '../../data/cart.js';
describe('test suite: addToCart', () => {
it('adds and exisiting product to the cart', () => {
});
it('add a new product to the cart', () => {
spyOn(localStorage, 'getItem').and.callFake(() => {
return JSON.stringify({});
});
console.log(localStorage.getItem('cart'));
addToCart('e43638ce-6aa0-4b85-b27f-e1d07eb678c6');
expect(cart.length).toEqual(1);
});
});
From - Lesson 16 (Testing)
Using Jasmine Testing Framework
The above lines of code is supposed to display an empty array in the console since the code is supposed to spyOn locaStorage('getItem')and call fake the cart array, but instead it's returning "null" in the console. I don't know where I went wrong. I need assistance, I have been trying to solve this issue for the past 3 days now.
Thanks.
Metadata
Metadata
Assignees
Labels
No labels