Created
July 6, 2022 15:13
-
-
Save pushkar100/2dd1176c96d4dc0ab653cf2f37d6a5b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* testing/src/__tests__/helpers/index.test.js */ | |
import { /* ... */ , setTraysForId, getTraysForId } from '../../helpers'; | |
describe('Trays', () => { | |
beforeEach(() => { | |
window.localStorage.clear(); | |
}); | |
test('are stored locally on setting them via the id', () => { | |
const id = 123; | |
const trays = ['movies', 'cartoons', 'true crime']; | |
const stringifiedTrays = JSON.stringify(trays); | |
setTraysForId(id, trays); | |
expect(window.localStorage.getItem(`${id}`)).toEqual(stringifiedTrays); | |
}); | |
test('are fetched locally on searching for them via the id', () => { | |
const id = 123; | |
const trays = ['movies', 'cartoons', 'true crime']; | |
const stringifiedTrays = JSON.stringify(trays); | |
setTraysForId(id, trays); | |
const actualTrays = getTraysForId(id); | |
expect(actualTrays).toEqual(trays); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment