|
| 1 | +'use strict' |
| 2 | +var test = require('tap').test |
| 3 | +var Tacks = require('tacks') |
| 4 | +var path = require('path') |
| 5 | +var Dir = Tacks.Dir |
| 6 | +var File = Tacks.File |
| 7 | +var common = require('../common-tap.js') |
| 8 | + |
| 9 | +var fixturepath = common.pkg |
| 10 | +var fixture = new Tacks(Dir({ |
| 11 | + 'package.json': File({ |
| 12 | + name: 'a', |
| 13 | + version: '0.0.0', |
| 14 | + dependencies: { 'hassupport': '7.7.7' } |
| 15 | + }), |
| 16 | + 'node_modules': Dir({ |
| 17 | + hassupport: Dir({ |
| 18 | + 'package.json': File({ |
| 19 | + name: 'hassupport', |
| 20 | + version: '7.7.7', |
| 21 | + homepage: 'http://example.com/project', |
| 22 | + support: 'http://example.com/project/donate' |
| 23 | + }) |
| 24 | + }) |
| 25 | + }) |
| 26 | +})) |
| 27 | + |
| 28 | +test('setup', function (t) { |
| 29 | + fixture.remove(fixturepath) |
| 30 | + fixture.create(fixturepath) |
| 31 | + t.end() |
| 32 | +}) |
| 33 | + |
| 34 | +test('support --json', function (t) { |
| 35 | + common.npm(['support', '--json'], {cwd: fixturepath}, function (err, code, stdout, stderr) { |
| 36 | + if (err) throw err |
| 37 | + t.is(code, 0, 'exited 0') |
| 38 | + t.is(stderr, '', 'no warnings') |
| 39 | + var parsed |
| 40 | + t.doesNotThrow(function () { |
| 41 | + parsed = JSON.parse(stdout) |
| 42 | + }, 'valid JSON') |
| 43 | + t.deepEqual( |
| 44 | + parsed, |
| 45 | + [ |
| 46 | + { |
| 47 | + name: 'hassupport', |
| 48 | + version: '7.7.7', |
| 49 | + homepage: 'http://example.com/project', |
| 50 | + support: 'http://example.com/project/donate', |
| 51 | + path: path.resolve(fixturepath, 'node_modules', 'hassupport') |
| 52 | + } |
| 53 | + ], |
| 54 | + 'output data' |
| 55 | + ) |
| 56 | + t.end() |
| 57 | + }) |
| 58 | +}) |
| 59 | + |
| 60 | +test('support', function (t) { |
| 61 | + common.npm(['support'], {cwd: fixturepath}, function (err, code, stdout, stderr) { |
| 62 | + if (err) throw err |
| 63 | + t.is(code, 0, 'exited 0') |
| 64 | + t.is(stderr, '', 'no warnings') |
| 65 | + t.includes(stdout, 'hassupport', 'outputs project name') |
| 66 | + t.includes(stdout, '7.7.7', 'outputs project version') |
| 67 | + t.includes(stdout, 'http://example.com/project', 'outputs contributor homepage') |
| 68 | + t.includes(stdout, 'http://example.com/project/donate', 'outputs support link') |
| 69 | + t.end() |
| 70 | + }) |
| 71 | +}) |
| 72 | + |
| 73 | +test('cleanup', function (t) { |
| 74 | + t.pass(fixturepath) |
| 75 | + fixture.remove(fixturepath) |
| 76 | + t.end() |
| 77 | +}) |
0 commit comments