Skip to content

Commit fee4137

Browse files
Andre StackhouseAndre Stackhouse
Andre Stackhouse
authored and
Andre Stackhouse
committed
Refactor tests to use arrow functions.
1 parent a98ecf6 commit fee4137

5 files changed

+41
-41
lines changed

test/check_permutation_test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
mocha.setup('bdd');
22

3-
describe('check_permutation_test', function() {
4-
describe('valid_permutation', function() {
5-
it('should return true for "read" and "dear"', function() {
3+
describe('check_permutation_test', () => {
4+
describe('valid_permutation', () => {
5+
it('should return true for "read" and "dear"', () => {
66
chai.assert.equal(check_permutation('read', 'dear'), true);
77
});
8-
it('should return true for equivalent strings', function() {
8+
it('should return true for equivalent strings', () => {
99
chai.assert.equal(check_permutation('equivalent', 'equivalent'), true);
1010
});
11-
it('should return true for two empty strings', function() {
11+
it('should return true for two empty strings', () => {
1212
chai.assert.equal(check_permutation('', ''), true);
1313
});
1414
});
15-
describe('invalid_permutation', function() {
16-
it('should return false for "noon" and "moon"', function() {
15+
describe('invalid_permutation', () => {
16+
it('should return false for "noon" and "moon"', () => {
1717
chai.assert.equal(check_permutation('noon', 'moon'), false);
1818
});
1919
});

test/corresponding_bracket_index_test.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
describe('corresponding_bracket_index_test', function() {
2-
describe('valid_source_code', function() {
3-
it('should return 6 when the caret index is 0', function() {
1+
describe('corresponding_bracket_index_test', () => {
2+
describe('valid_source_code', () => {
3+
it('should return 6 when the caret index is 0', () => {
44
chai.assert.equal(corresponding_bracket_index(valid_source_code, 0), 6);
55
});
66

7-
it('should return 0 when the caret index is 6', function() {
7+
it('should return 0 when the caret index is 6', () => {
88
chai.assert.equal(corresponding_bracket_index(valid_source_code, 6), 0);
99
});
1010

11-
it('should return 26 when the caret index is 9', function() {
11+
it('should return 26 when the caret index is 9', () => {
1212
chai.assert.equal(corresponding_bracket_index(valid_source_code, 9), 26);
1313
});
1414

15-
it('should return 8 when the caret index is 27', function() {
15+
it('should return 8 when the caret index is 27', () => {
1616
chai.assert.equal(corresponding_bracket_index(valid_source_code, 27), 8);
1717
});
1818
});
1919

2020
describe('invalid_source_code', () => {
21-
it('should throw "invalid brackets in source code" on improper nesting', function() {
21+
it('should throw "invalid brackets in source code" on improper nesting', () => {
2222
chai.assert.throws(() => { corresponding_bracket_index(improper_nesting, 2) }, Error, 'Invalid brackets in source code.');
2323
});
2424

25-
it('should throw "invalid brackets in source code" on incorrect closing bracket', function() {
25+
it('should throw "invalid brackets in source code" on incorrect closing bracket', () => {
2626
chai.assert.throws(() => { corresponding_bracket_index(wrong_closing_bracket, 2) }, Error, 'Invalid brackets in source code.');
2727
});
2828

29-
it('should throw "Unclosed brackets in source code" on unclosed bracket', function() {
29+
it('should throw "Unclosed brackets in source code" on unclosed bracket', () => {
3030
chai.assert.throws(() => { corresponding_bracket_index(unclosed_bracket, 2) }, Error, 'Unclosed brackets in source code.');
3131
});
3232

33-
it('should throw "Invalid caret index. Caret must point to a bracket" if no braces', function() {
33+
it('should throw "Invalid caret index. Caret must point to a bracket" if no braces', () => {
3434
chai.assert.throws(() => { corresponding_bracket_index(no_braces, 2) }, Error, 'Invalid caret index. Caret must point to a bracket.');
3535
});
3636

37-
it('should throw "Invalid caret index. Caret must point to a bracket" on invalid caret index', function() {
37+
it('should throw "Invalid caret index. Caret must point to a bracket" on invalid caret index', () => {
3838
chai.assert.throws(() => { corresponding_bracket_index(valid_source_code, 2) }, Error, 'Invalid caret index. Caret must point to a bracket.');
3939
});
4040
});

test/one_away_test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
describe('one_away_test', function() {
2-
describe('insert/remove', function() {
3-
it('should return true for "pale and "ple"', function() {
1+
describe('one_away_test', () => {
2+
describe('insert/remove', () => {
3+
it('should return true for "pale and "ple"', () => {
44
chai.assert.equal(one_away('pale', 'ple'), true);
55
});
6-
it('should return false for "pale and "pl"', function() {
6+
it('should return false for "pale and "pl"', () => {
77
chai.assert.equal(one_away('pale', 'pl'), false);
88
});
99
});
10-
describe('replace', function() {
11-
it('should return true for "pale" and "bale"', function() {
10+
describe('replace', () => {
11+
it('should return true for "pale" and "bale"', () => {
1212
chai.assert.equal(one_away("pale", "pales"), true);
1313
});
14-
it('should return false for "pale" and "bald"', function() {
14+
it('should return false for "pale" and "bald"', () => {
1515
chai.assert.equal(one_away("pale", "bald"), false);
1616
});
1717
});
1818
describe('equivalent', function () {
19-
it('should return true for "hello" and "hello"', function() {
19+
it('should return true for "hello" and "hello"', () => {
2020
chai.assert.equal(one_away("hello", "hello"), true);
2121
});
22-
it('should return true for two empty strings', function() {
22+
it('should return true for two empty strings', () => {
2323
chai.assert.equal(one_away("", ""), true);
2424
});
2525
});

test/sort_stack_test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
describe('sort_stack_test', function() {
2-
describe('mixed_order', function() {
3-
it('should return [6, 5, 4, 3, 2, 1]', function() {
1+
describe('sort_stack_test', () => {
2+
describe('mixed_order', () => {
3+
it('should return [6, 5, 4, 3, 2, 1]', () => {
44
chai.assert.deepEqual(sort_stack(mixed_order), [6, 5, 4, 3, 2, 1]);
55
});
66
});
7-
describe('sorted_order', function() {
8-
it('should return [10, 9, 8, 7, 6, 5]', function() {
7+
describe('sorted_order', () => {
8+
it('should return [10, 9, 8, 7, 6, 5]', () => {
99
chai.assert.deepEqual(sort_stack(sorted_order), [10, 9, 8, 7, 6, 5]);
1010
});
1111
});
12-
describe('reverse_sorted', function() {
13-
it('should return [95, 94, 93, 92, 91, 90]', function() {
12+
describe('reverse_sorted', () => {
13+
it('should return [95, 94, 93, 92, 91, 90]', () => {
1414
chai.assert.deepEqual(sort_stack(reverse_sorted), [95, 94, 93, 92, 91, 90]);
1515
});
1616
});

test/string_compression_test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
describe('string_compression_test', function() {
2-
describe('compressable_strings', function() {
3-
it('should return "a3b1c5a3" for "aaabcccccaaa"', function() {
1+
describe('string_compression_test', () => {
2+
describe('compressable_strings', () => {
3+
it('should return "a3b1c5a3" for "aaabcccccaaa"', () => {
44
chai.assert.deepEqual(string_compression('aaabcccccaaa'), 'a3b1c5a3');
55
});
6-
it('should return "r2e2d3i2t2" for "rreedddiitt"', function() {
6+
it('should return "r2e2d3i2t2" for "rreedddiitt"', () => {
77
chai.assert.deepEqual(string_compression('rreedddiitt'), 'r2e2d3i2t2');
88
});
99
});
10-
describe('uncompressable_strings', function() {
11-
it('should return "andre" for "andre"', function() {
10+
describe('uncompressable_strings', () => {
11+
it('should return "andre" for "andre"', () => {
1212
chai.assert.deepEqual(string_compression('andre'), 'andre');
1313
});
14-
it('should return "" for ""', function() {
14+
it('should return "" for ""', () => {
1515
chai.assert.deepEqual(string_compression(''), '');
1616
});
1717
});

0 commit comments

Comments
 (0)