• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict'
2
3const common = require('../common-tap.js')
4const path = require('path')
5const test = require('tap').test
6
7const Tacks = require('tacks')
8const File = Tacks.File
9const Dir = Tacks.Dir
10
11const basedir = common.pkg
12const testdir = path.join(basedir, 'testdir')
13
14const fixture = new Tacks(Dir({
15  cache: Dir(),
16  global: Dir(),
17  tmp: Dir(),
18  testdir: Dir({
19    'package-lock.json': File({
20      name: 'http-locks',
21      version: '1.0.0',
22      lockfileVersion: 1,
23      requires: true,
24      dependencies: {
25        minimist: {}
26      }
27    }),
28    'package.json': File({
29      name: 'http-locks',
30      version: '1.0.0',
31      dependencies: {
32        minimist: common.registry + '/minimist/-/minimist-0.0.5.tgz'
33      }
34    })
35  })
36}))
37
38function setup () {
39  cleanup()
40  fixture.create(basedir)
41}
42
43function cleanup () {
44  fixture.remove(basedir)
45}
46
47test('setup', function (t) {
48  setup()
49  t.done()
50})
51
52test('raises error to regenerate the lock file', function (t) {
53  common.npm(['install'], {cwd: testdir}, function (err, code, stdout, stderr) {
54    if (err) throw err
55    t.match(
56      stderr,
57      'npm ERR! Something went wrong. Regenerate the package-lock.json with "npm install".',
58      'returns message to regenerate package-lock'
59    )
60
61    t.done()
62  })
63})
64
65test('cleanup', function (t) {
66  cleanup()
67  t.done()
68})
69