text: /**
  * @license Apache-2.0
  *
  * Copyright (c) 2021 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 tape = require( 'tape' );
  var proxyquire = require( 'proxyquire' );
  var query = require( './../lib/query.js' );
  
  
  // FIXTURES //
  
  var getOpts = require( './fixtures/opts.js' );
  var data = require( './fixtures/results.json' );
  var info = require( './fixtures/info.json' );
  var response = {
  	'headers': {
  		'x-ratelimit-limit': info.limit.toString(),
  		'x-ratelimit-remaining': info.remaining.toString(),
  		'x-ratelimit-reset': info.reset.toString()
  	}
  };
  
  
  // TESTS //
  
  tape( 'main export is a function', function test( t ) {
  	t.ok( true, __filename );
  	t.equal( typeof query, 'function', 'export is a function' );
  	t.end();
  });
  
  tape( 'function returns an error to a provided callback if an error is encountered when creating a token (no rate limit info)', function test( t ) {
  	var query;
  	var opts;
  
  	query = proxyquire( './../lib/query.js', {
  		'./request.js': request
  	});
  
  	opts = getOpts();
  	query( opts, done );
  
  	function request( opts, data, clbk ) {
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			clbk( new Error( 'beep' ) );
  		}
  	}
  
  	function done( error ) {
  		t.ok( error instanceof Error, 'error instance' );
  		t.equal( error.message, 'beep' );
  		t.end();
  	}
  });
  
  tape( 'function returns an error to a provided callback if an error is encountered when creating a token (rate limit info)', function test( t ) {
  	var query;
  	var opts;
  
  	query = proxyquire( './../lib/query.js', {
  		'./request.js': request
  	});
  
  	opts = getOpts();
  	query( opts, done );
  
  	function request( opts, data, clbk ) {
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			clbk( new Error( 'beep' ), response );
  		}
  	}
  
  	function done( error ) {
  		t.ok( error instanceof Error, 'error instance' );
  		t.equal( error.message, 'beep' );
  		t.end();
  	}
  });
  
  tape( 'function returns response data to a provided callback', function test( t ) {
  	var expected;
  	var query;
  	var opts;
  
  	query = proxyquire( './../lib/query.js', {
  		'./request.js': request
  	});
  
  	expected = data;
  
  	opts = getOpts();
  	query( opts, done );
  
  	function request( opts, body, clbk ) {
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			clbk( null, response, data );
  		}
  	}
  
  	function done( error, data ) {
  		if ( error ) {
  			t.fail( error.message );
  		}
  		t.deepEqual( data, expected, 'deep equal' );
  		t.end();
  	}
  });
  
  tape( 'function returns rate limit info to a provided callback', function test( t ) {
  	var expected;
  	var query;
  	var opts;
  
  	query = proxyquire( './../lib/query.js', {
  		'./request.js': request
  	});
  
  	expected = info;
  
  	opts = getOpts();
  	query( opts, done );
  
  	function request( opts, body, clbk ) {
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			clbk( null, response, data );
  		}
  	}
  
  	function done( error, data, info ) {
  		if ( error ) {
  			t.fail( error.message );
  		}
  		t.deepEqual( info, expected, 'deep equal' );
  		t.end();
  	}
  });
  
  tape( 'function returns rate limit info to a provided callback (error)', function test( t ) {
  	var expected;
  	var query;
  	var opts;
  
  	query = proxyquire( './../lib/query.js', {
  		'./request.js': request
  	});
  
  	expected = info;
  
  	opts = getOpts();
  	query( opts, done );
  
  	function request( opts, body, clbk ) {
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			clbk( new Error( 'beep' ), response );
  		}
  	}
  
  	function done( error, data, info ) {
  		t.ok( error, 'returns an error' );
  		t.equal( data, null, 'no data' );
  
  		t.deepEqual( info, expected, 'deep equal' );
  
  		t.end();
  	}
  });
  