/**
* @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 tape = require( 'tape' );
var RuleTester = require( 'eslint' ).RuleTester;
var rule = require( './../lib' );


// FIXTURES //

var valid = require( './fixtures/valid.js' );
var invalid = require( './fixtures/invalid.js' );
var unvalidated = require( './fixtures/unvalidated.js' );


// TESTS //

tape( 'main export is an object', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof rule, 'object', 'main export is an object' );
	t.end();
});

tape( 'the function positively validates code where all `require()` calls are sorted in a a specified order', function test( t ) {
	var tester = new RuleTester();

	try {
		tester.run( 'order-require', rule, {
			'valid': valid,
			'invalid': []
		});
		t.pass( 'passed without errors' );
	} catch ( err ) {
		t.fail( 'encountered an error: ' + err.message );
	}
	t.end();
});

tape( 'the function negatively validates code where not all `require()` calls are sorted in a specified order', function test( t ) {
	var tester = new RuleTester();

	try {
		tester.run( 'order-require', rule, {
			'valid': [],
			'invalid': invalid
		});
		t.pass( 'passed without errors' );
	} catch ( err ) {
		t.fail( 'encountered an error: ' + err.message );
	}
	t.end();
});

tape( 'the function does not validate other function calls', function test( t ) {
	var tester = new RuleTester();

	try {
		tester.run( 'order-require', rule, {
			'valid': unvalidated,
			'invalid': []
		});
		t.pass( 'passed without errors' );
	} catch ( err ) {
		t.fail( 'encountered an error: ' + err.message );
	}
	t.end();
});


/**
* @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 tape = require( 'tape' );
var RuleTester = require( 'eslint' ).RuleTester;
var rule = require( './../lib' );


// FIXTURES //

var valid = require( './fixtures/valid.js' );
var invalid = require( './fixtures/invalid.js' );
var unvalidated = require( './fixtures/unvalidated.js' );


// TESTS //

tape( 'main export is an object', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof rule, 'object', 'main export is an object' );
	t.end();
});

tape( 'the function positively validates code where all `require()` calls are sorted in a a specified order', function test( t ) {
	var tester = new RuleTester();

	try {
		tester.run( 'require-order', rule, {
			'valid': valid,
			'invalid': []
		});
		t.pass( 'passed without errors' );
	} catch ( err ) {
		t.fail( 'encountered an error: ' + err.message );
	}
	t.end();
});

tape( 'the function negatively validates code where not all `require()` calls are sorted in a specified order', function test( t ) {
	var tester = new RuleTester();

	try {
		tester.run( 'require-order', rule, {
			'valid': [],
			'invalid': invalid
		});
		t.pass( 'passed without errors' );
	} catch ( err ) {
		t.fail( 'encountered an error: ' + err.message );
	}
	t.end();
});

tape( 'the function does not validate other function calls', function test( t ) {
	var tester = new RuleTester();

	try {
		tester.run( 'require-order', rule, {
			'valid': unvalidated,
			'invalid': []
		});
		t.pass( 'passed without errors' );
	} catch ( err ) {
		t.fail( 'encountered an error: ' + err.message );
	}
	t.end();
});


Fix rule name