test: write()

This commit is contained in:
Zoltan Kochan
2018-01-03 03:14:08 +02:00
parent 58af6ef797
commit 05532f1aff

View File

@@ -3,6 +3,7 @@ import {
readCurrent,
readPrivate,
read,
write,
writeWantedOnly,
} from 'pnpm-shrinkwrap'
import test = require('tape')
@@ -97,3 +98,43 @@ test('writeWantedOnly()', async t => {
t.deepEqual(await readWanted(projectPath, {ignoreIncompatible: false}), wantedShrinkwrap)
t.end()
})
test('write()', async t => {
const projectPath = tempy.directory()
const wantedShrinkwrap = {
shrinkwrapVersion: 3,
registry: 'https://registry.npmjs.org',
dependencies: {
'is-positive': '1.0.0',
'is-negative': '1.0.0',
},
specifiers: {
'is-positive': '^1.0.0',
'is-negative': '^1.0.0',
},
packages: {
'/is-positive/1.0.0': {
resolution: {
integrity: 'sha1-ChbBDewTLAqLCzb793Fo5VDvg/g='
}
},
'/is-negative/1.0.0': {
dependencies: {
'is-positive': '2.0.0',
},
resolution: {
integrity: 'sha1-ChbBDewTLAqLCzb793Fo5VDvg/g='
}
},
'/is-positive/2.0.0': {
resolution: {
integrity: 'sha1-ChbBDewTLAqLCzb793Fo5VDvg/g='
}
},
}
}
await write(projectPath, wantedShrinkwrap, wantedShrinkwrap)
t.deepEqual(await readCurrent(projectPath, {ignoreIncompatible: false}), wantedShrinkwrap)
t.deepEqual(await readWanted(projectPath, {ignoreIncompatible: false}), wantedShrinkwrap)
t.end()
})