Skip to content

Commit 602a428

Browse files
authored
test(compat/{negate,add,set}): fix duplicate test titles and enable 'vitest/no-identical-title' error (#1535)
1 parent 340b178 commit 602a428

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

eslint.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export default defineConfig(
5555
...vitest.configs.recommended.rules,
5656
'vitest/no-commented-out-tests': 'warn',
5757
'vitest/valid-expect': 'warn',
58-
'vitest/no-identical-title': 'warn',
5958
},
6059
},
6160
prettier,

src/compat/function/negate.spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ describe('negate', () => {
1515
expect(negateFn(2)).toBe(false);
1616
});
1717

18-
it('should create a function that negates the result of `func`', () => {
19-
const negateFn = negate(isEven);
20-
21-
expect(negateFn(1)).toBe(true);
22-
expect(negateFn(2)).toBe(false);
23-
});
24-
2518
it('should create a function that accepts multiple arguments', () => {
2619
let argCount: any;
2720
const count = 5;

src/compat/math/add.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ describe('add', () => {
2121
expect(add('x', 'y')).toBe('xy');
2222
});
2323

24-
it('should return the sum of two valid numbers', () => {
24+
it('should return the sum of two positive numbers', () => {
2525
expect(add(2, 3)).toBe(5);
2626
});
2727

28-
it('should return the sum of two valid numbers', () => {
28+
it('should return the sum of two negative numbers', () => {
2929
expect(add(-1, -5)).toBe(-6);
3030
});
3131

32-
it('should return the sum of two valid numbers', () => {
32+
it('should return the sum of a negative and a positive number', () => {
3333
expect(add(-2, 3)).toBe(1);
3434
});
3535

src/compat/object/set.spec.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('set', () => {
3030
expect(result).toEqual({ a: { b: 1 } });
3131
});
3232

33-
it('should set a value on an object with nested path', () => {
33+
it('should set a value on an object with deeply nested path', () => {
3434
const result = set<{ a: { b: { c: { d: number } } } }>({} as { a: { b: { c: { d: number } } } }, 'a.b.c.d', 1);
3535
expect(result).toEqual({ a: { b: { c: { d: 1 } } } });
3636
});
@@ -44,18 +44,19 @@ describe('set', () => {
4444
expect(result[0]).toEqual(1);
4545
});
4646

47-
it('should set a value on an array with nested path', () => {
47+
it('should set a value on an array with nested path of depth 2', () => {
4848
const result = set<number[][]>([] as number[][], '0.0', 1);
4949
expect(result).toEqual([[1]]);
5050
expect(result[0][0]).toEqual(1);
5151
});
5252

53-
it('should set a value on an array with nested path', () => {
53+
it('should set a value on an array with nested path of depth 3', () => {
5454
const result = set<number[][][]>([], '0.0.0', 1);
5555
expect(result).toEqual([[[1]]]);
5656
expect(result[0][0][0]).toEqual(1);
5757
});
58-
it('should set a value on an array with nested path', () => {
58+
59+
it('should set a value on an existing array at a specific index', () => {
5960
const arr = [1, 2, 3];
6061
set(arr, 1, 4);
6162
expect(arr).toEqual([1, 4, 3]);
@@ -65,25 +66,25 @@ describe('set', () => {
6566
//--------------------------------------------------------------------------------
6667
// object and array
6768
//--------------------------------------------------------------------------------
68-
it('should set a value on an object and array', () => {
69+
it('should set a value on an array containing an object', () => {
6970
const result = set<Array<{ a: number }>>([] as Array<{ a: number }>, '0.a', 1);
7071
expect(result).toEqual([{ a: 1 }]);
7172
expect(result[0].a).toEqual(1);
7273
});
7374

74-
it('should set a value on an object and array', () => {
75+
it('should set a value on an object containing an array', () => {
7576
const result = set<{ a: number[] }>({} as { a: number[] }, 'a.0', 1);
7677
expect(result).toEqual({ a: [1] });
7778
expect(result.a[0]).toEqual(1);
7879
});
7980

80-
it('should set a value on an object and array', () => {
81+
it('should set a value on an object containing nested arrays', () => {
8182
const result = set<{ a: number[][] }>({} as { a: number[][] }, 'a.0.0', 1);
8283
expect(result).toEqual({ a: [[1]] });
8384
expect(result.a[0][0]).toEqual(1);
8485
});
8586

86-
it('should set a value on an object and array', () => {
87+
it('should set a value on an object containing deeply nested arrays with bracket notation', () => {
8788
const result = set<{ a: number[][][] }>({} as { a: number[][][] }, 'a[0][0][0]', 1);
8889
expect(result).toEqual({ a: [[[1]]] });
8990
expect(result.a[0][0][0]).toEqual(1);

0 commit comments

Comments
 (0)