Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('cores have separate plugins', async () => {
// Setup
const { _fs } = await makeFixture('test-cores')
plugins.set('fs', _fs)
cores.create('third').set('foo', _fs)
expect(cores.get('default').has('fs')).toBeTruthy()
expect(cores.get('default').has('foo')).toBeFalsy()
expect(cores.get('third').has('fs')).toBeFalsy()
expect(cores.get('third').get('foo')).toBeTruthy()
})
it('plugin schema violation', async () => {
it('core.create', async () => {
// Setup
const { _fs } = await makeFixture('test-cores')
cores.get('default').set('fs', _fs)
let error = null
try {
cores.create('second').set('fs', _fs)
} catch (err) {
error = err
}
expect(error).toBeNull()
expect(cores.get('second').get('fs')).toBe(_fs)
})
it('cores have separate plugins', async () => {
async function makeLightningFS (dir) {
const FS = require('@isomorphic-git/lightning-fs')
const _fs = new FS(`testfs`, {
wipe: true,
url: `http://${localhost}:9876/base/__tests__/__fixtures__`
})
const core = `core-lightningfs-${i++}`
cores.create(core).set('fs', _fs)
plugins.set('fs', _fs) // deprecated
const fs = new FileSystem(_fs)
dir = `/${dir}`
const gitdir = `/${dir}.git`
await fs.mkdir(dir)
await fs.mkdir(gitdir)
return { _fs, fs, dir, gitdir, core }
}
async function makeNodeFixture (fixture) {
const _fs = Object.assign({}, require('fs'))
const core = `core-node-${i++}`
cores.create(core).set('fs', _fs)
plugins.set('fs', _fs) // deprecated
const fs = new FileSystem(_fs)
const {
getFixturePath,
createTempDir,
copyFixtureIntoTempDir
} = require('jest-fixtures')
const testsDir = path.resolve(__dirname, '..')
const dir = (await getFixturePath(testsDir, fixture))
? await copyFixtureIntoTempDir(testsDir, fixture)
: await createTempDir()
const index = require('../../__fixtures__/index.json')
const readable = await HTTPRequestFS({
index,
baseUrl: '/base/__tests__/__fixtures__/'
})
const writable = await InMemoryFS()
const ofs = await OverlayFS({ readable, writable })
BrowserFS.initialize(ofs)
browserFS = BrowserFS.BFSRequire('fs')
browserFSwritable = writable
}
const _fs = Object.assign({}, browserFS)
browserFSwritable.empty()
const core = `core-browserfs-${i++}`
cores.create(core).set('fs', _fs)
plugins.set('fs', _fs) // deprecated
const fs = new FileSystem(_fs)
dir = `/${dir}`
const gitdir = `/${dir}.git`
await fs.mkdir(dir)
await fs.mkdir(gitdir)
return {
_fs,
fs,
dir,
gitdir,
core
}
}