Skip to content

Commit

Permalink
Remove logging and set item in test
Browse files Browse the repository at this point in the history
  • Loading branch information
xander-marjoram committed Apr 26, 2024
1 parent 7393e98 commit 9699bb9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,10 @@ const fullAddressLocalStorageService = {
},

getItem (key) {
console.log('================');
console.log('window is', window);
console.log('window.localStorage is', window.localStorage);
console.log('JSON is', JSON);
if (window.localStorage) {
const item = window.localStorage.getItem(key);
console.log('item is', item);
return item ? JSON.parse(item) : false;
}
console.log('================');

return false;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe('`general.services`', () => {

it('should return an item when the key exists in localStorage', () => {
// Arrange
jest.spyOn(window.localStorage, 'getItem');
generalServices.fullAddressLocalStorageService.setItem('key', { city: 'london' });

// Act
const result = generalServices.fullAddressLocalStorageService.getItem('key');
Expand All @@ -278,11 +278,8 @@ describe('`general.services`', () => {
expect(result).toEqual({ city: 'london' });
});

it('should return false when the key does NOT exists in localStorage', () => {
// Arrange
jest.spyOn(window.localStorage, 'getItem');

// Act
it('should return false when the key does NOT exist in localStorage', () => {
// Arrange & Act
const result = generalServices.fullAddressLocalStorageService.getItem('non-existing-key');

// Assert
Expand Down

0 comments on commit 9699bb9

Please sign in to comment.