text: /**
  * @license Apache-2.0
  *
  * Copyright (c) 2018 The Stdlib Authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  
  'use strict';
  
  // MODULES //
  
  var resolve = require( 'path' ).resolve;
  var join = require( 'path' ).join;
  var tape = require( 'tape' );
  var proxyquire = require( 'proxyquire' );
  var noop = require( '@stdlib/utils/noop' );
  var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
  var isArray = require( '@stdlib/assert/is-array' );
  var findREADMEs = require( './../lib/main.js' );
  
  
  // VARIABLES //
  
  var dir = resolve( __dirname, '..' );
  
  
  // TESTS //
  
  tape( 'main export is a function', function test( t ) {
  	t.ok( true, __filename );
  	t.strictEqual( typeof findREADMEs, 'function', 'main export is a function' );
  	t.end();
  });
  
  tape( 'the function throws an error if provided an invalid option', function test( t ) {
  	t.throws( foo, TypeError, 'throws error' );
  	t.end();
  	function foo() {
  		var opts = {
  			'dir': null
  		};
  		findREADMEs( opts, noop );
  	}
  });
  
  tape( 'if provided a callback argument which is not a function, the function throws an error (no options)', function test( t ) {
  	var values;
  	var i;
  
  	values = [
  		'5',
  		5,
  		NaN,
  		true,
  		null,
  		undefined,
  		[],
  		{}
  	];
  
  	for ( i = 0; i < values.length; i++ ) {
  		t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
  	}
  	t.end();
  
  	function badValue( value ) {
  		return function badValue() {
  			findREADMEs( value );
  		};
  	}
  });
  
  tape( 'if provided a callback argument which is not a function, the function throws an error (options)', function test( t ) {
  	var values;
  	var i;
  
  	values = [
  		'5',
  		5,
  		NaN,
  		true,
  		null,
  		undefined,
  		[],
  		{}
  	];
  
  	for ( i = 0; i < values.length; i++ ) {
  		t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
  	}
  	t.end();
  
  	function badValue( value ) {
  		return function badValue() {
  			findREADMEs( {}, value );
  		};
  	}
  });
  
  tape( 'the function returns an error to a provided callback if an error is encountered while searching a directory', function test( t ) {
  	var findREADMEs = proxyquire( './../lib/main.js', {
  		'glob': glob
  	});
  
  	findREADMEs( clbk );
  
  	function glob() {
  		var cb = arguments[ arguments.length-1 ];
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			cb( new Error( 'beep' ) );
  		}
  	}
  
  	function clbk( error ) {
  		t.ok( error, 'returns an error' );
  		t.end();
  	}
  });
  
  tape( 'the function returns an error to a provided callback if an error is encountered while resolving package READMEs', function test( t ) {
  	var findREADMEs;
  	var opts;
  
  	findREADMEs = proxyquire( './../lib/main.js', {
  		'./find.js': mock
  	});
  	opts = {
  		'dir': dir
  	};
  
  	findREADMEs( opts, clbk );
  
  	function mock() {
  		var cb = arguments[ arguments.length-1 ];
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			cb( new Error( 'beep' ) );
  		}
  	}
  
  	function clbk( error ) {
  		t.ok( error, 'returns an error' );
  		t.end();
  	}
  });
  
  tape( 'the function returns an empty array if unable to resolve any packages', function test( t ) {
  	var findREADMEs = proxyquire( './../lib/main.js', {
  		'glob': glob
  	});
  
  	findREADMEs( clbk );
  
  	function glob() {
  		var cb = arguments[ arguments.length-1 ];
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			cb( null, [] );
  		}
  	}
  
  	function clbk( error, files ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isArray( files ), true, 'returns an array' );
  		t.strictEqual( files.length, 0, 'returns an empty array' );
  		t.end();
  	}
  });
  
  tape( 'the function returns a string array (if at least one package README is found)', function test( t ) {
  	var findREADMEs;
  	var opts;
  
  	findREADMEs = proxyquire( './../lib/main.js', {
  		'./find.js': mock
  	});
  
  	opts = {
  		'dir': dir
  	};
  	findREADMEs( opts, clbk );
  
  	function mock() {
  		var clbk = arguments[ arguments.length-1 ];
  		clbk( null, [ join( dir, 'README.md' ) ] );
  	}
  
  	function clbk( error, files ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isStringArray( files ), true, 'returns a string array' );
  		t.end();
  	}
  });
  