From 05532f1affc10896fca7495bc0bec24f08e8e2a1 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 3 Jan 2018 03:14:08 +0200 Subject: [PATCH] test: write() --- test/read.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/read.ts b/test/read.ts index c7b08bb71e..621e6b33c4 100644 --- a/test/read.ts +++ b/test/read.ts @@ -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() +})