Skip to content

Commit

Permalink
Removed some globals from tests (#3712)
Browse files Browse the repository at this point in the history
* `chai` is no longer global

* sinon is no longer globally defined

* expect(..) is no longer defined globally

* Removed obsolete eslint hints about globals

* Removed unused variable ( `expect(..)` )
  • Loading branch information
briandamaged committed Mar 8, 2020
1 parent d00bd8d commit 9d07bc9
Show file tree
Hide file tree
Showing 25 changed files with 43 additions and 42 deletions.
5 changes: 2 additions & 3 deletions test/chai-setup.js
@@ -1,6 +1,5 @@
const chai = (global.chai = require('chai'));
const chai = require('chai');

chai.should();
chai.use(require('chai-as-promised'));

global.expect = chai.expect;
chai.use(require('sinon-chai'));
2 changes: 0 additions & 2 deletions test/index.js
Expand Up @@ -3,9 +3,7 @@

require('source-map-support').install();

global.sinon = require('sinon');
require('./chai-setup');
global.chai.use(require('sinon-chai'));

global.d = new Date();

Expand Down
3 changes: 2 additions & 1 deletion test/integration/builder/additional.js
@@ -1,7 +1,8 @@
/*global expect*/
/*eslint no-var:0, max-len:0 */
'use strict';

const { expect } = require('chai');

const Knex = require('../../../knex');
const _ = require('lodash');
const delay = require('../../../lib/util/delay');
Expand Down
1 change: 0 additions & 1 deletion test/integration/builder/deletes.js
@@ -1,5 +1,4 @@
/*global d*/

'use strict';

module.exports = function(knex) {
Expand Down
5 changes: 3 additions & 2 deletions test/integration/builder/inserts.js
@@ -1,7 +1,8 @@
/*global expect, d*/

/*global d*/
'use strict';

const { expect } = require('chai');

const uuid = require('uuid');
const _ = require('lodash');
const sinon = require('sinon');
Expand Down
4 changes: 3 additions & 1 deletion test/integration/builder/selects.js
@@ -1,6 +1,8 @@
/*global expect, d*/
/*global d*/
'use strict';

const { expect } = require('chai');

const _ = require('lodash');
const assert = require('assert');
const Runner = require('../../../lib/runner');
Expand Down
4 changes: 2 additions & 2 deletions test/integration/builder/transaction.js
@@ -1,7 +1,7 @@
/*global expect*/

'use strict';

const { expect } = require('chai');

const Knex = require('../../../knex');
const _ = require('lodash');
const sinon = require('sinon');
Expand Down
5 changes: 3 additions & 2 deletions test/integration/builder/updates.js
@@ -1,7 +1,8 @@
/*global expect, d*/

/*global d*/
'use strict';

const { expect } = require('chai');

module.exports = function(knex) {
describe('Updates', function() {
it('should handle updates', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/connection-config-provider.js
@@ -1,7 +1,7 @@
/*global expect*/

'use strict';

const { expect } = require('chai');

const _ = require('lodash');
const makeKnex = require('../../knex');

Expand Down
4 changes: 2 additions & 2 deletions test/integration/datatype/bigint.js
@@ -1,7 +1,7 @@
/*global expect*/

'use strict';

const { expect } = require('chai');

module.exports = function(knex) {
const bigintTimestamp = 1464294366973;
const negativeBigintTimestamp = -1464294366973;
Expand Down
4 changes: 3 additions & 1 deletion test/integration/logger.js
@@ -1,7 +1,9 @@
/*global expect, d*/
/*global d*/

'use strict';

const { expect } = require('chai');

const _ = require('lodash');

module.exports = function(knex) {
Expand Down
3 changes: 2 additions & 1 deletion test/integration/migrate/index.js
@@ -1,6 +1,7 @@
/*global expect*/
'use strict';

const { expect } = require('chai');

const equal = require('assert').equal;
const fs = require('fs');
const path = require('path');
Expand Down
4 changes: 2 additions & 2 deletions test/integration/schema/index.js
@@ -1,7 +1,7 @@
/*global expect*/

'use strict';

const { expect } = require('chai');

const _ = require('lodash');

const wrapIdentifier = (value, wrap) => {
Expand Down
3 changes: 2 additions & 1 deletion test/integration/seed/index.js
@@ -1,6 +1,7 @@
/*global expect*/
'use strict';

const { expect } = require('chai');

const path = require('path');
const rimraf = require('rimraf');

Expand Down
4 changes: 2 additions & 2 deletions test/integration/suite.js
@@ -1,7 +1,7 @@
/*global expect*/

'use strict';

const { expect } = require('chai');

module.exports = function(knex) {
const sinon = require('sinon');

Expand Down
2 changes: 0 additions & 2 deletions test/unit/dialects/mssql.js
@@ -1,5 +1,3 @@
// global it, describe

'use strict';
const expect = require('chai').expect;
const knex = require('../../../knex');
Expand Down
2 changes: 0 additions & 2 deletions test/unit/dialects/oracledb.js
@@ -1,5 +1,3 @@
// global it, describe

'use strict';
const _ = require('lodash');
const expect = require('chai').expect;
Expand Down
3 changes: 1 addition & 2 deletions test/unit/dialects/sqlite3.js
@@ -1,6 +1,5 @@
// global it, describe, expect

'use strict';

const sinon = require('sinon');
const DDL = require('../../../lib/dialects/sqlite3/schema/ddl');

Expand Down
2 changes: 1 addition & 1 deletion test/unit/schema/mysql.js
@@ -1,4 +1,4 @@
/*global expect*/
const { expect } = require('chai');

const sinon = require('sinon');
const MySQL_Client = require('../../../lib/dialects/mysql');
Expand Down
4 changes: 2 additions & 2 deletions test/unit/schema/oracle.js
@@ -1,7 +1,7 @@
/*global expect*/

'use strict';

const { expect } = require('chai');

const sinon = require('sinon');
const Oracle_Client = require('../../../lib/dialects/oracle');
const client = new Oracle_Client({ client: 'oracledb' });
Expand Down
4 changes: 2 additions & 2 deletions test/unit/schema/oracledb.js
@@ -1,7 +1,7 @@
/*global expect*/

'use strict';

const { expect } = require('chai');

const sinon = require('sinon');
const Oracle_Client = require('../../../lib/dialects/oracledb');
const client = new Oracle_Client({ client: 'oracledb' });
Expand Down
2 changes: 1 addition & 1 deletion test/unit/schema/postgres.js
@@ -1,4 +1,4 @@
/*global expect*/
const { expect } = require('chai');

let tableSql;

Expand Down
4 changes: 2 additions & 2 deletions test/unit/schema/redshift.js
@@ -1,8 +1,8 @@
/*global expect*/
/* eslint max-len:0 */

'use strict';

const { expect } = require('chai');

let tableSql;

const Redshift_Client = require('../../../lib/dialects/redshift');
Expand Down
4 changes: 2 additions & 2 deletions test/unit/schema/sqlite3.js
@@ -1,7 +1,7 @@
/*global expect*/

'use strict';

const { expect } = require('chai');

let tableSql;

const sinon = require('sinon');
Expand Down
3 changes: 2 additions & 1 deletion test/unit/seed/seeder.js
@@ -1,7 +1,8 @@
/*global expect*/
/*eslint no-var:0, indent:0, max-len:0 */
'use strict';

const { expect } = require('chai');

const mockFs = require('mock-fs');
const knex = require('../../../knex');

Expand Down

0 comments on commit 9d07bc9

Please sign in to comment.