Skip to content

Commit 1e01d7f

Browse files
committed
Removed the use of global scope assertion/stub libraries
to make the dependencies visible
1 parent 721d669 commit 1e01d7f

19 files changed

+34
-11
lines changed

cli-test-mocha.opts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
--ui tdd
2-
--require test/bootstrap.js
32
--recursive
43
test

test/.eslintrc.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
globals:
2-
expect: true
3-
sinon: true
42
suite: true
53
test: true
64
beforeEach: true
7-
stubWithArgs: true
85
rules:
96
no-unused-expressions: off

test/bootstrap.js renamed to test/helpers.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
const chai = require('chai')
22
chai.use(require('sinon-chai'))
33

4-
global.expect = chai.expect
5-
global.sinon = require('sinon')
6-
global.throwErrorIfCalled = () => {
4+
const sinon = require('sinon')
5+
6+
exports.expect = chai.expect
7+
exports.sinon = sinon
8+
exports.throwErrorIfCalled = () => {
79
throw new Error("Shouldn't have been called")
810
}
911

1012
// Usage: stubWithArgs([call1Arg1, ...], return1, [call2Arg1, ...], return2, ...)
11-
global.stubWithArgs = function (...args) {
13+
exports.stubWithArgs = function (...args) {
1214
const stub = sinon.stub()
1315
for (let i = 0; i + 1 < args.length; i += 2) {
1416
stub.withArgs.apply(stub, args[i]).returns(args[i + 1])

test/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,4 @@ testRunner.configure({
1919
useColors: true // colored output from test results
2020
})
2121

22-
require('./bootstrap')
23-
2422
module.exports = testRunner

test/lib/bootstrapper.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const td = require('testdouble')
2+
const { expect } = require('../helpers')
23

34
const Bootstrapper = require('../../lib/bootstrapper')
45

test/lib/clipboard.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { expect } = require('../helpers')
2+
13
const Clipboard = require('../../lib/clipboard')
24

35
suite('Clipboard', () => {

test/lib/commands/compare-selection-with-clipboard.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { expect, sinon, stubWithArgs } = require('../../helpers')
2+
13
const CompareSelectionWithClipboardCommand = require('../../../lib/commands/compare-selection-with-clipboard')
24

35
suite('CompareSelectionWithClipboardCommand', () => {

test/lib/commands/compare-selection-with-text1.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { expect, sinon, stubWithArgs } = require('../../helpers')
2+
13
const CompareSelectionWithText1 = require('../../../lib/commands/compare-selection-with-text1')
24

35
suite('CompareSelectionWithText1', () => {

test/lib/commands/compare-visible-editors.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const CompareVisibleEditorsCommand = require('../../../lib/commands/compare-visible-editors')
21
const td = require('testdouble')
32

3+
const CompareVisibleEditorsCommand = require('../../../lib/commands/compare-visible-editors')
4+
45
suite('CompareVisibleEditorsCommand', () => {
56
const editor1 = { viewColumn: 1 }
67
const editor2 = { viewColumn: 2 }

test/lib/commands/save-text-1.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { expect, sinon, stubWithArgs } = require('../../helpers')
2+
13
const SelectText1Command = require('../../../lib/commands/save-text-1')
24

35
suite('SelectText1Command', () => {

0 commit comments

Comments
 (0)