Convert mocha callbacks from arrows to regular functions · ClearQuest/github@d5e55f8 · GitHub
Skip to content

Commit d5e55f8

Browse files
committed
Convert mocha callbacks from arrows to regular functions
... in order to access the Mocha context in tests
1 parent 0861338 commit d5e55f8

33 files changed

Lines changed: 455 additions & 454 deletions

test/.eslintrc

Lines changed: 1 addition & 0 deletions

test/async-assertions.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {until} from './helpers'; // eslint-disable-line no-unused-vars
22

3-
describe('assert.async', () => {
4-
it('allows for asynchronous assertions', async () => {
3+
describe('assert.async', function() {
4+
it('allows for asynchronous assertions', async function() {
55
let val = false;
66
setTimeout(() => { val = true; });
77
await assert.async.isTrue(val);
88
});
99

10-
it('allows for setting the timeout', async () => {
10+
it('allows for setting the timeout', async function() {
1111
let val = false;
1212
setTimeout(() => { val = true; }, 100);
1313
let caught = false;
@@ -20,7 +20,7 @@ describe('assert.async', () => {
2020
assert.isTrue(caught);
2121
});
2222

23-
it('retains the assertion message and adds the timeout', async () => {
23+
it('retains the assertion message and adds the timeout', async function() {
2424
let val = false;
2525
setTimeout(() => { val = true; }, 100);
2626
let caught = null;

test/async-queue.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const timer = n => {
66
});
77
};
88

9-
describe('AsyncQueue', () => {
10-
it('runs items in the order queued', async () => {
9+
describe('AsyncQueue', function() {
10+
it('runs items in the order queued', async function() {
1111
const queue = new AsyncQueue();
1212

1313
const expectedEvents = [];
@@ -23,7 +23,7 @@ describe('AsyncQueue', () => {
2323
assert.deepEqual(expectedEvents, actualEvents);
2424
});
2525

26-
it('continues running queued items when one fails', async () => {
26+
it('continues running queued items when one fails', async function() {
2727
const queue = new AsyncQueue();
2828

2929
const expectedEvents = [];

test/controllers/commit-view-controller.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import CommitViewController from '../../lib/controllers/commit-view-controller';
22
import {cloneRepository, buildRepository} from '../helpers';
33

4-
describe('CommitViewController', () => {
4+
describe('CommitViewController', function() {
55
let atomEnvironment, commandRegistry;
66

7-
beforeEach(() => {
7+
beforeEach(function() {
88
atomEnvironment = global.buildAtomEnvironment();
99
commandRegistry = atomEnvironment.commands;
1010
});
1111

12-
afterEach(() => {
12+
afterEach(function() {
1313
atomEnvironment.destroy();
1414
});
1515

16-
it('correctly updates state when switching repos', async () => {
16+
it('correctly updates state when switching repos', async function() {
1717
const workdirPath1 = await cloneRepository('three-files');
1818
const repository1 = await buildRepository(workdirPath1);
1919
const workdirPath2 = await cloneRepository('three-files');
@@ -35,44 +35,44 @@ describe('CommitViewController', () => {
3535
assert.equal(controller.amendingCommitMessage, 'amending message 1');
3636
});
3737

38-
describe('the passed commit message', () => {
38+
describe('the passed commit message', function() {
3939
let controller, commitView, lastCommit;
40-
beforeEach(async () => {
40+
beforeEach(async function() {
4141
const workdirPath = await cloneRepository('three-files');
4242
const repository = await buildRepository(workdirPath);
4343
controller = new CommitViewController({commandRegistry, repository});
4444
commitView = controller.refs.commitView;
4545
lastCommit = {sha: 'a1e23fd45', message: 'last commit message'};
4646
});
4747

48-
it('is set to the regularCommitMessage in the default case', async () => {
48+
it('is set to the regularCommitMessage in the default case', async function() {
4949
controller.regularCommitMessage = 'regular message';
5050
await controller.update();
5151
assert.equal(commitView.props.message, 'regular message');
5252
});
5353

54-
describe('when isAmending is true', () => {
55-
it('is set to the last commits message if amendingCommitMessage is blank', async () => {
54+
describe('when isAmending is true', function() {
55+
it('is set to the last commits message if amendingCommitMessage is blank', async function() {
5656
controller.amendingCommitMessage = 'amending commit message';
5757
await controller.update({isAmending: true, lastCommit});
5858
assert.equal(commitView.props.message, 'amending commit message');
5959
});
6060

61-
it('is set to amendingCommitMessage if it is set', async () => {
61+
it('is set to amendingCommitMessage if it is set', async function() {
6262
controller.amendingCommitMessage = 'amending commit message';
6363
await controller.update({isAmending: true, lastCommit});
6464
assert.equal(commitView.props.message, 'amending commit message');
6565
});
6666
});
6767

68-
describe('when a merge message is defined', () => {
69-
it('is set to the merge message if regularCommitMessage is blank', async () => {
68+
describe('when a merge message is defined', function() {
69+
it('is set to the merge message if regularCommitMessage is blank', async function() {
7070
controller.regularCommitMessage = '';
7171
await controller.update({mergeMessage: 'merge conflict!'});
7272
assert.equal(commitView.props.message, 'merge conflict!');
7373
});
7474

75-
it('is set to regularCommitMessage if it is set', async () => {
75+
it('is set to regularCommitMessage if it is set', async function() {
7676
controller.regularCommitMessage = 'regular commit message';
7777
await controller.update({mergeMessage: 'merge conflict!'});
7878
assert.equal(commitView.props.message, 'regular commit message');

test/controllers/file-patch-controller.test.js

Lines changed: 13 additions & 13 deletions

0 commit comments

Comments
 (0)