11cb0ef41Sopenharmony_ciconst t = require('tap') 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst InstallTest = require('../../../lib/commands/install-test.js') 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_cilet installArgs = null 61cb0ef41Sopenharmony_cilet installCalled = false 71cb0ef41Sopenharmony_cilet testArgs = null 81cb0ef41Sopenharmony_cilet testCalled = false 91cb0ef41Sopenharmony_cilet installError = null 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst installTest = new InstallTest({ 121cb0ef41Sopenharmony_ci exec: (cmd, args) => { 131cb0ef41Sopenharmony_ci if (cmd === 'install') { 141cb0ef41Sopenharmony_ci installArgs = args 151cb0ef41Sopenharmony_ci installCalled = true 161cb0ef41Sopenharmony_ci } 171cb0ef41Sopenharmony_ci if (installError) { 181cb0ef41Sopenharmony_ci throw installError 191cb0ef41Sopenharmony_ci } 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci if (cmd === 'test') { 221cb0ef41Sopenharmony_ci testArgs = args 231cb0ef41Sopenharmony_ci testCalled = true 241cb0ef41Sopenharmony_ci } 251cb0ef41Sopenharmony_ci }, 261cb0ef41Sopenharmony_ci config: { 271cb0ef41Sopenharmony_ci validate: () => {}, 281cb0ef41Sopenharmony_ci get: (key) => { 291cb0ef41Sopenharmony_ci if (key === 'location') { 301cb0ef41Sopenharmony_ci return 'project' 311cb0ef41Sopenharmony_ci } 321cb0ef41Sopenharmony_ci }, 331cb0ef41Sopenharmony_ci isDefault: () => {}, 341cb0ef41Sopenharmony_ci }, 351cb0ef41Sopenharmony_ci}) 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_cit.test('the install-test command', t => { 381cb0ef41Sopenharmony_ci t.afterEach(() => { 391cb0ef41Sopenharmony_ci installArgs = null 401cb0ef41Sopenharmony_ci installCalled = false 411cb0ef41Sopenharmony_ci testArgs = null 421cb0ef41Sopenharmony_ci testCalled = false 431cb0ef41Sopenharmony_ci installError = null 441cb0ef41Sopenharmony_ci }) 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci t.test('install and test', async t => { 471cb0ef41Sopenharmony_ci await installTest.exec(['extra']) 481cb0ef41Sopenharmony_ci t.equal(installCalled, true) 491cb0ef41Sopenharmony_ci t.equal(testCalled, true) 501cb0ef41Sopenharmony_ci t.match(installArgs, ['extra']) 511cb0ef41Sopenharmony_ci t.match(testArgs, []) 521cb0ef41Sopenharmony_ci }) 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci t.test('install fails', async t => { 551cb0ef41Sopenharmony_ci installError = new Error('test fail') 561cb0ef41Sopenharmony_ci await t.rejects( 571cb0ef41Sopenharmony_ci installTest.exec(['extra']), 581cb0ef41Sopenharmony_ci 'test fail' 591cb0ef41Sopenharmony_ci ) 601cb0ef41Sopenharmony_ci t.equal(installCalled, true) 611cb0ef41Sopenharmony_ci t.equal(testCalled, false) 621cb0ef41Sopenharmony_ci t.match(installArgs, ['extra']) 631cb0ef41Sopenharmony_ci }) 641cb0ef41Sopenharmony_ci t.end() 651cb0ef41Sopenharmony_ci}) 66