mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-20 13:11:44 +00:00
resolved conflict
This commit is contained in:
36
tests/lib/find-storage.test.js
Normal file
36
tests/lib/find-storage.test.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const { findStorage } = require('browser/lib/findStorage')
|
||||
|
||||
global.document = require('jsdom').jsdom('<body></body>')
|
||||
global.window = document.defaultView
|
||||
global.navigator = window.navigator
|
||||
|
||||
const Storage = require('dom-storage')
|
||||
const localStorage = (window.localStorage = global.localStorage = new Storage(
|
||||
null,
|
||||
{ strict: true }
|
||||
))
|
||||
const path = require('path')
|
||||
const TestDummy = require('../fixtures/TestDummy')
|
||||
const sander = require('sander')
|
||||
const os = require('os')
|
||||
const storagePath = path.join(os.tmpdir(), 'test/find-storage')
|
||||
|
||||
let storageContext
|
||||
|
||||
beforeEach(() => {
|
||||
storageContext = TestDummy.dummyStorage(storagePath)
|
||||
localStorage.setItem('storages', JSON.stringify([storageContext.cache]))
|
||||
})
|
||||
|
||||
// Unit test
|
||||
test('findStorage() should return a correct storage path(string)', () => {
|
||||
const storageKey = storageContext.cache.key
|
||||
|
||||
expect(findStorage(storageKey).key).toBe(storageKey)
|
||||
expect(findStorage(storageKey).path).toBe(storagePath)
|
||||
})
|
||||
|
||||
afterAll(function after() {
|
||||
localStorage.clear()
|
||||
sander.rimrafSync(storagePath)
|
||||
})
|
||||
Reference in New Issue
Block a user