11cb0ef41Sopenharmony_ciconst t = require('tap') 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst dym = require('../../../lib/utils/did-you-mean.js') 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_cit.test('did-you-mean', async t => { 61cb0ef41Sopenharmony_ci t.test('with package.json', async t => { 71cb0ef41Sopenharmony_ci const testdir = t.testdir({ 81cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 91cb0ef41Sopenharmony_ci bin: { 101cb0ef41Sopenharmony_ci npx: 'exists', 111cb0ef41Sopenharmony_ci }, 121cb0ef41Sopenharmony_ci scripts: { 131cb0ef41Sopenharmony_ci install: 'exists', 141cb0ef41Sopenharmony_ci posttest: 'exists', 151cb0ef41Sopenharmony_ci }, 161cb0ef41Sopenharmony_ci }), 171cb0ef41Sopenharmony_ci }) 181cb0ef41Sopenharmony_ci t.test('nistall', async t => { 191cb0ef41Sopenharmony_ci const result = await dym(testdir, 'nistall') 201cb0ef41Sopenharmony_ci t.match(result, 'npm install') 211cb0ef41Sopenharmony_ci }) 221cb0ef41Sopenharmony_ci t.test('sttest', async t => { 231cb0ef41Sopenharmony_ci const result = await dym(testdir, 'sttest') 241cb0ef41Sopenharmony_ci t.match(result, 'npm test') 251cb0ef41Sopenharmony_ci t.match(result, 'npm run posttest') 261cb0ef41Sopenharmony_ci }) 271cb0ef41Sopenharmony_ci t.test('npz', async t => { 281cb0ef41Sopenharmony_ci const result = await dym(testdir, 'npxx') 291cb0ef41Sopenharmony_ci t.match(result, 'npm exec npx') 301cb0ef41Sopenharmony_ci }) 311cb0ef41Sopenharmony_ci t.test('qwuijbo', async t => { 321cb0ef41Sopenharmony_ci const result = await dym(testdir, 'qwuijbo') 331cb0ef41Sopenharmony_ci t.match(result, '') 341cb0ef41Sopenharmony_ci }) 351cb0ef41Sopenharmony_ci }) 361cb0ef41Sopenharmony_ci t.test('with no package.json', t => { 371cb0ef41Sopenharmony_ci const testdir = t.testdir({}) 381cb0ef41Sopenharmony_ci t.test('nistall', async t => { 391cb0ef41Sopenharmony_ci const result = await dym(testdir, 'nistall') 401cb0ef41Sopenharmony_ci t.match(result, 'npm install') 411cb0ef41Sopenharmony_ci }) 421cb0ef41Sopenharmony_ci t.end() 431cb0ef41Sopenharmony_ci }) 441cb0ef41Sopenharmony_ci t.test('missing bin and script properties', async t => { 451cb0ef41Sopenharmony_ci const testdir = t.testdir({ 461cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 471cb0ef41Sopenharmony_ci name: 'missing-bin', 481cb0ef41Sopenharmony_ci }), 491cb0ef41Sopenharmony_ci }) 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci const result = await dym(testdir, 'nistall') 521cb0ef41Sopenharmony_ci t.match(result, 'npm install') 531cb0ef41Sopenharmony_ci }) 541cb0ef41Sopenharmony_ci}) 55