import rimraf = require ( 'rimraf-then' ) ; import { installPkgs , storeStatus } from 'supi' ; import tape = require ( 'tape' ) ; import promisifyTape from 'tape-promise' ; import { prepare , testDefaults } from './utils' ; const test = promisifyTape ( tape ) ; test ( 'store status returns empty array when store was not modified' , async ( t ) => { const project = prepare ( t ) ; const opts = await testDefaults ( ) ; await installPkgs ( [ 'is-positive@3.1.0' ] , opts ) ; const mutatedPkgs = await storeStatus ( opts ) ; t . equal ( mutatedPkgs && mutatedPkgs . length , 0 , 'no packages were modified' ) ; } ) ; test ( 'store status does not fail on not installed optional dependencies' , async ( t ) => { const project = prepare ( t ) ; const opts = await testDefaults ( { saveOptional : true } ) ; await installPkgs ( [ 'not-compatible-with-any-os' ] , opts ) ; const mutatedPkgs = await storeStatus ( opts ) ; t . equal ( mutatedPkgs && mutatedPkgs . length , 0 , 'no packages were modified' ) ; } ) ; test ( 'store status returns path to the modified package' , async ( t ) => { const project = prepare ( t ) ; const opts = await testDefaults ( ) ; await installPkgs ( [ 'is-positive@3.1.0' ] , opts ) ; const isPositive = await project . resolve ( 'is-positive' , '3.1.0' , 'index.js' ) ; await rimraf ( isPositive ) ; const mutatedPkgs = await storeStatus ( opts ) ; t . equal ( mutatedPkgs && mutatedPkgs . length , 1 , '1 package was modified' ) ; t . ok ( mutatedPkgs && mutatedPkgs [ 0 ] . indexOf ( 'is-positive' ) !== - 1 , 'is-positive was modified' ) ; } ) ;