1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-19 04:31:46 +00:00

jest-codemods tests/lib

This commit is contained in:
amedora
2019-08-07 14:17:48 +09:00
parent 606be4304d
commit ffb2603485
12 changed files with 92 additions and 104 deletions

View File

@@ -1,4 +1,3 @@
const test = require('ava')
const { findStorage } = require('browser/lib/findStorage')
global.document = require('jsdom').jsdom('<body></body>')
@@ -13,20 +12,20 @@ const sander = require('sander')
const os = require('os')
const storagePath = path.join(os.tmpdir(), 'test/find-storage')
test.beforeEach((t) => {
beforeEach(() => {
t.context.storage = TestDummy.dummyStorage(storagePath)
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
})
// Unit test
test('findStorage() should return a correct storage path(string)', t => {
test('findStorage() should return a correct storage path(string)', () => {
const storageKey = t.context.storage.cache.key
t.is(findStorage(storageKey).key, storageKey)
t.is(findStorage(storageKey).path, storagePath)
expect(findStorage(storageKey).key).toBe(storageKey)
expect(findStorage(storageKey).path).toBe(storagePath)
})
test.after(function after () {
afterAll(function after () {
localStorage.clear()
sander.rimrafSync(storagePath)
})