|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
| 6 | +import { describe, test, expect } from '@jest/globals'; |
6 | 7 | import * as path from 'path';
|
7 | 8 |
|
8 | 9 | import { isSubfolderOf, safeLength, sum } from '../../src/common';
|
9 | 10 |
|
10 |
| -import { should, expect } from 'chai'; |
11 |
| - |
12 |
| -suite('Common', () => { |
13 |
| - suiteSetup(() => should()); |
14 |
| - |
15 |
| - suite('safeLength', () => { |
| 11 | +describe('Common', () => { |
| 12 | + describe('safeLength', () => { |
16 | 13 | test('return 0 for empty array', () => {
|
17 | 14 | const array: any[] = [];
|
18 | 15 | const result = safeLength(array);
|
19 |
| - result.should.equal(0); |
| 16 | + expect(result).toBe(0); |
20 | 17 | });
|
21 | 18 |
|
22 | 19 | test('returns 5 for array of 5 elements', () => {
|
23 | 20 | const array = [1, 2, 3, 4, 5];
|
24 | 21 | const result = safeLength(array);
|
25 |
| - result.should.equal(5); |
| 22 | + expect(result).toBe(5); |
26 | 23 | });
|
27 | 24 |
|
28 | 25 | test('returns 0 for undefined', () => {
|
29 | 26 | const array = undefined;
|
30 | 27 | const result = safeLength(array);
|
31 |
| - result.should.equal(0); |
| 28 | + expect(result).toBe(0); |
32 | 29 | });
|
33 | 30 | });
|
34 | 31 |
|
35 |
| - suite('sum', () => { |
| 32 | + describe('sum', () => { |
36 | 33 | test('produce total from numbers', () => {
|
37 | 34 | const array = [1, 2, 3, 4, 5];
|
38 | 35 | const result = sum(array, (i) => i);
|
39 |
| - result.should.equal(15); |
| 36 | + expect(result).toBe(15); |
40 | 37 | });
|
41 | 38 |
|
42 | 39 | test('produce total from lengths of arrays', () => {
|
43 | 40 | const array = [[1, 2], [3], [], [4, 5, 6]];
|
44 | 41 | const result = sum(array, (i) => i.length);
|
45 |
| - result.should.equal(6); |
| 42 | + expect(result).toBe(6); |
46 | 43 | });
|
47 | 44 |
|
48 | 45 | test('produce total of true values from array of booleans', () => {
|
49 | 46 | const array = [true, false, false, true, true, true, false, true];
|
50 | 47 | const result = sum(array, (b) => (b ? 1 : 0));
|
51 |
| - result.should.equal(5); |
| 48 | + expect(result).toBe(5); |
52 | 49 | });
|
53 | 50 | });
|
54 | 51 |
|
55 |
| - suite('isSubfolderOf', () => { |
| 52 | + describe('isSubfolderOf', () => { |
56 | 53 | test('same paths', () => {
|
57 | 54 | const subfolder: string = ['C:', 'temp', 'VS', 'dotnetProject'].join(path.sep);
|
58 | 55 | const folder: string = ['C:', 'temp', 'VS', 'dotnetProject'].join(path.sep);
|
59 | 56 |
|
60 |
| - expect(isSubfolderOf(subfolder, folder)).to.be.true; |
| 57 | + expect(isSubfolderOf(subfolder, folder)).toBe(true); |
61 | 58 | });
|
62 | 59 |
|
63 | 60 | test('correct subfolder', () => {
|
64 |
| - const subfolder: string = ['C:', 'temp', 'VS'].join(path.sep); |
65 |
| - const folder: string = ['C:', 'temp', 'VS', 'dotnetProject'].join(path.sep); |
| 61 | + const folder: string = ['C:', 'temp', 'VS'].join(path.sep); |
| 62 | + const subfolder: string = ['C:', 'temp', 'VS', 'dotnetProject'].join(path.sep); |
66 | 63 |
|
67 |
| - expect(isSubfolderOf(subfolder, folder)).to.be.true; |
| 64 | + expect(isSubfolderOf(subfolder, folder)).toBe(true); |
68 | 65 | });
|
69 | 66 |
|
70 |
| - test('longer subfolder', () => { |
71 |
| - const subfolder: string = ['C:', 'temp', 'VS', 'a', 'b', 'c'].join(path.sep); |
72 |
| - const folder: string = ['C:', 'temp', 'VS'].join(path.sep); |
| 67 | + test('longer folder', () => { |
| 68 | + const folder: string = ['C:', 'temp', 'VS', 'a', 'b', 'c'].join(path.sep); |
| 69 | + const subfolder: string = ['C:', 'temp', 'VS'].join(path.sep); |
73 | 70 |
|
74 |
| - expect(isSubfolderOf(subfolder, folder)).to.be.false; |
| 71 | + expect(isSubfolderOf(subfolder, folder)).toBe(false); |
75 | 72 | });
|
76 | 73 |
|
77 | 74 | test('Different drive', () => {
|
78 | 75 | const subfolder: string = ['C:', 'temp', 'VS'].join(path.sep);
|
79 | 76 | const folder: string = ['E:', 'temp', 'VS'].join(path.sep);
|
80 | 77 |
|
81 |
| - expect(isSubfolderOf(subfolder, folder)).to.be.false; |
| 78 | + expect(isSubfolderOf(subfolder, folder)).toBe(false); |
82 | 79 | });
|
83 | 80 | });
|
84 | 81 | });
|
0 commit comments