mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-24 10:01:48 -04:00
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import rimraf = require('rimraf-then')
|
|
import {install, installPkgs} from 'supi'
|
|
import tape = require('tape')
|
|
import promisifyTape from 'tape-promise'
|
|
import {
|
|
prepare,
|
|
testDefaults,
|
|
} from './utils'
|
|
|
|
const test = promisifyTape(tape)
|
|
|
|
test('offline installation fails when package meta not found in local registry mirror', async (t) => {
|
|
const project = prepare(t)
|
|
|
|
try {
|
|
await installPkgs(['is-positive@3.0.0'], await testDefaults({}, {offline: true}, {offline: true}))
|
|
t.fail('installation should have failed')
|
|
} catch (err) {
|
|
t.equal(err.code, 'NO_OFFLINE_META', 'failed with correct error code')
|
|
}
|
|
})
|
|
|
|
test('offline installation fails when package tarball not found in local registry mirror', async (t) => {
|
|
const project = prepare(t)
|
|
|
|
await installPkgs(['is-positive@3.0.0'], await testDefaults())
|
|
|
|
await rimraf('node_modules')
|
|
|
|
try {
|
|
await installPkgs(['is-positive@3.1.0'], await testDefaults({}, {offline: true}, {offline: true}))
|
|
t.fail('installation should have failed')
|
|
} catch (err) {
|
|
t.equal(err.code, 'NO_OFFLINE_TARBALL', 'failed with correct error code')
|
|
}
|
|
})
|
|
|
|
test('successful offline installation', async (t) => {
|
|
const project = prepare(t)
|
|
|
|
await installPkgs(['is-positive@3.0.0'], await testDefaults({save: true}))
|
|
|
|
await rimraf('node_modules')
|
|
|
|
await install(await testDefaults({}, {offline: true}, {offline: true}))
|
|
|
|
const m = project.requireModule('is-positive')
|
|
t.ok(typeof m === 'function', 'module is available')
|
|
})
|