Skip to content

Commit 335011b

Browse files
authored
test: improve test assertions and remove 'vitest/expect-expect', 'vitest/valid-title' from ESLint warn rules (toss#1531)
1 parent 7a91f7a commit 335011b

24 files changed

+43
-48
lines changed

eslint.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ export default defineConfig(
5454
rules: {
5555
...vitest.configs.recommended.rules,
5656
'vitest/no-commented-out-tests': 'warn',
57-
'vitest/expect-expect': 'warn',
5857
'vitest/valid-expect': 'warn',
5958
'vitest/no-identical-title': 'warn',
60-
'vitest/valid-title': 'warn',
6159
},
6260
},
6361
prettier,

src/compat/array/some.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('some', () => {
3737
count++;
3838
return value;
3939
})
40-
);
40+
).toBe(true);
4141

4242
expect(count).toBe(2);
4343
});

src/compat/function/attempt.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('attempt', () => {
6666
const actual = attempt(() => {
6767
throw new CustomError('x');
6868
});
69-
expect(actual instanceof CustomError);
69+
expect(actual instanceof CustomError).toBe(true);
7070
});
7171

7272
it('should match the type of lodash', () => {

src/compat/function/bind.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ describe('bind', () => {
3737
const bound = bind(fn, null);
3838
const actual = bound('a');
3939

40-
expect(actual[0] === null);
40+
expect(actual[0]).toBe(null);
4141
expect(actual[1]).toBe('a');
4242

4343
const bound2 = bind(fn, undefined);
4444
const actual2 = bound2('b');
4545

46-
expect(actual2[0] === undefined);
46+
expect(actual2[0]).toBe(undefined);
4747
expect(actual2[1]).toBe('b');
4848

4949
const bound3 = (bind as any)(fn);
5050
const actual3 = bound3('b');
5151

52-
expect(actual3[0] === undefined);
52+
expect(actual3[0]).toBe(undefined);
5353
expect(actual3[1]).toBe('b');
5454
});
5555

@@ -100,7 +100,7 @@ describe('bind', () => {
100100

101101
expect(bound().a).toBe(1);
102102
expect(newBound.a).toBe(undefined);
103-
expect(newBound instanceof Foo);
103+
expect(newBound instanceof Foo).toBe(true);
104104
});
105105

106106
it('should handle a number of arguments when called with the `new` operator', () => {
@@ -135,7 +135,7 @@ describe('bind', () => {
135135
const bound = (bind as any)(Foo) as any;
136136
const object = {};
137137

138-
expect(new bound() instanceof Foo);
138+
expect(new bound() instanceof Foo).toBe(true);
139139
expect(new bound(true)).toBe(object);
140140
});
141141

src/compat/function/curry.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('curry', () => {
9090
const object = {};
9191

9292
// @ts-expect-error - curried is a constructor
93-
expect(new curried(false) instanceof Foo);
93+
expect(new curried(false) instanceof Foo).toBe(true);
9494

9595
// @ts-expect-error - curried is a constructor
9696
expect(new curried(true)).toBe(object);

src/compat/function/curryRight.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('curryRight', () => {
8888
const object = {};
8989

9090
// @ts-expect-error - curried is a constructor
91-
expect(new curried(false) instanceof Foo);
91+
expect(new curried(false) instanceof Foo).toBe(true);
9292

9393
// @ts-expect-error - curried is a constructor
9494
expect(new curried(true)).toBe(object);

src/compat/function/debounce.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ describe('debounce', () => {
439439
const methodName = 'debounce';
440440

441441
it(`\`_.${methodName}\` should not error for non-object \`options\` values`, () => {
442-
func(noop, 32, 1 as any);
443-
expect(true);
442+
expect(() => func(noop, 32, 1 as any)).not.toThrow();
444443
});
445444

446445
it(`\`_.${methodName}\` should use a default \`wait\` of \`0\``, async () => {

src/compat/function/defer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('defer', () => {
3131
clearTimeout(timerId);
3232

3333
setTimeout(() => {
34-
expect(pass);
34+
expect(pass).toBe(true);
3535
done();
3636
}, 32);
3737
});

src/compat/function/throttle.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ describe('throttle', () => {
211211
const methodName = 'throttle';
212212

213213
it(`\`_.${methodName}\` should not error for non-object \`options\` values`, () => {
214-
func(noop, 32, 1 as any);
215-
expect(true);
214+
expect(() => func(noop, 32, 1 as any)).not.toThrow();
216215
});
217216

218217
it(`\`_.${methodName}\` should use a default \`wait\` of \`0\``, async () => {

src/compat/math/random.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ describe('random', () => {
5656
const result = random(min, max);
5757
return result >= min && result <= max;
5858
})
59-
).toBeTruthy();
59+
).toBe(true);
6060

61-
expect(array.some(() => random(Number.MAX_SAFE_INTEGER)));
61+
expect(array.some(() => random(Number.MAX_SAFE_INTEGER))).toBe(true);
6262
});
6363

6464
it('should coerce arguments to finite numbers', () => {

0 commit comments

Comments
 (0)