Skip to content

Commit f5d8fd6

Browse files
committed
refactor: improve test descriptions for clarity and consistency
Signed-off-by: Vladislav Polyakov <[email protected]>
1 parent 6fd4cd4 commit f5d8fd6

File tree

14 files changed

+63
-64
lines changed

14 files changed

+63
-64
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,4 @@ jobs:
5656
node-version: ${{ matrix.node-version }}
5757

5858
- run: npm run build
59-
- run: npm run test -- --no-color
60-
- run: npm run test:e2e -- --no-color
59+
- run: npm run test:all

packages/auth/src/accestoken.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from "vitest";
22

33
import { AccessTokenCredentialsProvider } from "./access-token.ts";
44

5-
test('valid token', async () => {
5+
test('parses valid token', async () => {
66
let provider = new AccessTokenCredentialsProvider({ token: 'test-token' });
77
let token = await provider.getToken();
88
expect(token).eq('test-token');

packages/auth/src/metadata.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ afterEach(() => {
66
vi.restoreAllMocks()
77
})
88

9-
test('valid token', async () => {
9+
test('extracts valid token', async () => {
1010
global.fetch = vi.fn(async () => {
1111
let response = new Response(JSON.stringify({ access_token: 'test-token' }))
1212
response.headers.set('Content-Type', 'application/json')
@@ -20,7 +20,7 @@ test('valid token', async () => {
2020
expect(token, 'Token is not empty').eq('test-token')
2121
})
2222

23-
test('invalid response', async () => {
23+
test('handles invalid response', async () => {
2424
global.fetch = vi.fn(async () => {
2525
let response = new Response('404 Not Found', { status: 404 })
2626

packages/core/tests/driver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, inject, test } from 'vitest'
22

33
import { Driver } from '../dist/esm/driver.js'
44

5-
test('driver ready', async () => {
5+
test('initializes driver ready', async () => {
66
let driver = new Driver(inject('connectionString'), {
77
'ydb.sdk.discovery_timeout_ms': 1000,
88
})

packages/error/src/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { create } from '@bufbuild/protobuf'
44
import { IssueMessageSchema, StatusIds_StatusCode } from '@ydbjs/api/operation'
55
import { CommitError, YDBError } from './index.ts'
66

7-
test('single issue', () => {
7+
test('handles single issue', () => {
88
let error = new YDBError(StatusIds_StatusCode.ABORTED, [
99
create(IssueMessageSchema, {
1010
severity: 1,
@@ -36,7 +36,7 @@ test('single issue', () => {
3636
expect(error.message).eq('ABORTED, Issues: ERROR(1030): Type annotation')
3737
})
3838

39-
test('multiple issues', () => {
39+
test('handles multiple issues', () => {
4040
let error = new YDBError(StatusIds_StatusCode.ABORTED, [
4141
create(IssueMessageSchema, {
4242
severity: 0,
@@ -54,7 +54,7 @@ test('multiple issues', () => {
5454
expect(error.message).eq('ABORTED, Issues: FATAL(14): Some error message; ERROR(15): Another error message')
5555
})
5656

57-
test('commit error', () => {
57+
test('creates commit error', () => {
5858
let error = new CommitError('Commit failed', new YDBError(StatusIds_StatusCode.ABORTED, []))
5959

6060
expect(error.message).eq('Commit failed')

packages/query/src/yql.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { expect, test } from 'vitest'
33
import { Int32 } from '@ydbjs/value/primitive'
44
import { identifier, yql } from './yql.ts'
55

6-
test('string', () => {
6+
test('processes string template', () => {
77
let { text } = yql`SELECT 1;`
88

99
expect(text).eq('SELECT 1;')
1010
})
1111

12-
test('string with js value as parameter', () => {
12+
test('processes string with js value as parameter', () => {
1313
let { text, params } = yql`SELECT ${1};`
1414

1515
expect(text).eq('SELECT $p0;')
@@ -23,7 +23,7 @@ test('string with js value as parameter', () => {
2323
`)
2424
})
2525

26-
test('string with ydb value as parameter', () => {
26+
test('processes string with ydb value as parameter', () => {
2727
let { text, params } = yql`SELECT ${new Int32(1)};`
2828

2929
expect(text).eq('SELECT $p0;')
@@ -37,7 +37,7 @@ test('string with ydb value as parameter', () => {
3737
`)
3838
})
3939

40-
test('string with parameters and identifiers', () => {
40+
test('processes string with parameters and identifiers', () => {
4141
let { text, params } = yql`FROM ${identifier('my_table')}.${identifier('my_column')} SELECT ${1}, ${2};`
4242

4343
expect(text).eq('FROM `my_table`.`my_column` SELECT $p0, $p1;')

packages/query/tests/query.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { query } from '../dist/esm/index.js'
1010
let driver = new Driver(inject('connectionString'), { 'ydb.sdk.enable_discovery': false })
1111
await driver.ready()
1212

13-
test('Simple query', async () => {
13+
test('executes simple query', async () => {
1414
let sql = query(driver)
1515

1616
expect(await sql`SELECT 1 AS id`).toMatchInlineSnapshot(`
@@ -24,7 +24,7 @@ test('Simple query', async () => {
2424
`)
2525
})
2626

27-
test('Query with parameters', async () => {
27+
test('executes query with parameters', async () => {
2828
let sql = query(driver)
2929

3030
let resultSets = await sql`SELECT ${1} AS id`
@@ -39,7 +39,7 @@ test('Query with parameters', async () => {
3939
`)
4040
})
4141

42-
test('Query with named parameters', async () => {
42+
test('executes query with named parameters', async () => {
4343
let sql = query(driver)
4444

4545
let resultSets = await sql`SELECT $param1 as id`.parameter('param1', fromJs(1))
@@ -54,7 +54,7 @@ test('Query with named parameters', async () => {
5454
`)
5555
})
5656

57-
test('Query with named parameters and types', async () => {
57+
test('executes query with named parameters and types', async () => {
5858
let sql = query(driver)
5959

6060
let resultSets = await sql`SELECT $param1 as id`.parameter('param1', new Uint64(1n))
@@ -69,7 +69,7 @@ test('Query with named parameters and types', async () => {
6969
`)
7070
})
7171

72-
test('Query with multiple parameters', async () => {
72+
test('executes query with multiple parameters', async () => {
7373
let sql = query(driver)
7474

7575
let resultSets = await sql`SELECT $param1 as id, ${'Neo'} as name`.parameter('param1', fromJs(1))
@@ -85,7 +85,7 @@ test('Query with multiple parameters', async () => {
8585
`)
8686
})
8787

88-
test('Query with multiple result sets', async () => {
88+
test('executes query with multiple result sets', async () => {
8989
let sql = query(driver)
9090

9191
let resultSets = await sql`SELECT 1 AS id; SELECT 2 AS id`
@@ -105,7 +105,7 @@ test('Query with multiple result sets', async () => {
105105
`)
106106
})
107107

108-
test('Query with multiple result sets and parameters', async () => {
108+
test('executes query with multiple result sets and parameters', async () => {
109109
let sql = query(driver)
110110

111111
let resultSets = await sql`SELECT $param1 AS id; SELECT $param2 AS id`
@@ -128,7 +128,7 @@ test('Query with multiple result sets and parameters', async () => {
128128
`)
129129
})
130130

131-
test('Query with CAST', async () => {
131+
test('executes query with CAST', async () => {
132132
let sql = query(driver)
133133

134134
let resultSets = await sql`SELECT CAST($param1 as Uint64) AS id`.parameter('param1', fromJs(1))
@@ -144,7 +144,7 @@ test('Query with CAST', async () => {
144144
`)
145145
})
146146

147-
test('Query with typed value', async () => {
147+
test('executes query with typed value', async () => {
148148
let sql = query(driver)
149149

150150
let resultSets = await sql`SELECT ${new Uint64(1n)} AS id`
@@ -159,7 +159,7 @@ test('Query with typed value', async () => {
159159
`)
160160
})
161161

162-
test('Query with optional value', async () => {
162+
test('executes query with optional value', async () => {
163163
let sql = query(driver)
164164

165165
let resultSets = await sql`SELECT CAST(${new Optional(null, new Uint64Type())} AS Uint64?) AS id`
@@ -174,7 +174,7 @@ test('Query with optional value', async () => {
174174
`)
175175
})
176176

177-
test('Query with table parameter using AS_TABLE', async () => {
177+
test('executes query with table parameter using AS_TABLE', async () => {
178178
let sql = query(driver)
179179

180180
let resultSets = await sql`SELECT * FROM AS_TABLE(${[{ id: 1, name: 'Neo' }]})`
@@ -190,7 +190,7 @@ test('Query with table parameter using AS_TABLE', async () => {
190190
`)
191191
})
192192

193-
test('Query with list of structs', async () => {
193+
test('executes query with list of structs', async () => {
194194
let sql = query(driver)
195195

196196
let resultSets = await sql`SELECT * FROM AS_TABLE(${[
@@ -215,7 +215,7 @@ test('Query with list of structs', async () => {
215215
`)
216216
})
217217

218-
test('Simple transaction', async () => {
218+
test('executes simple transaction', async () => {
219219
let sql = query(driver)
220220

221221
let resultSets = await sql.begin(async (tx) => {
@@ -233,7 +233,7 @@ test('Simple transaction', async () => {
233233
`)
234234
})
235235

236-
test('Transaction with parameters', async () => {
236+
test('executes transaction with parameters', async () => {
237237
let sql = query(driver)
238238

239239
let resultSets = await sql.begin(async (tx) => {
@@ -251,7 +251,7 @@ test('Transaction with parameters', async () => {
251251
`)
252252
})
253253

254-
test('Transaction with multiple queries', async () => {
254+
test('executes transaction with multiple queries', async () => {
255255
let sql = query(driver)
256256

257257
let resultSets = await sql.begin(async (tx) => {
@@ -271,7 +271,7 @@ test('Transaction with multiple queries', async () => {
271271
`)
272272
})
273273

274-
test('Parallel transactions and queries', async () => {
274+
test('executes parallel transactions and queries', async () => {
275275
let sql = query(driver)
276276

277277
let results = await Promise.all([

packages/retry/src/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { retry } from './index.ts'
44

55
let isError = (error: unknown) => error instanceof Error
66

7-
test('do retry', async () => {
7+
test('retries operation successfully', async () => {
88
let attempts = 0
99

1010
let result = retry({ retry: isError, budget: Infinity }, async () => {
@@ -20,7 +20,7 @@ test('do retry', async () => {
2020
expect(attempts).eq(3)
2121
})
2222

23-
test('budget exceeded', async () => {
23+
test('stops when budget exceeded', async () => {
2424
let attempts = 0
2525

2626
let result = retry({ retry: isError, budget: 0 }, async () => {

packages/retry/src/strategy.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { expect, test } from 'vitest'
33
import { defaultRetryConfig } from './index.ts'
44
import * as strategies from './strategy.ts'
55

6-
test('fixed', async () => {
6+
test('applies fixed delay strategy', async () => {
77
let strategy = strategies.fixed(1000)
88

99
let delay = strategy({ attempt: 0, error: new Error('test') }, defaultRetryConfig)
1010
expect(delay).eq(1000)
1111
})
1212

13-
test('linear', async () => {
13+
test('applies linear backoff strategy', async () => {
1414
let strategy = strategies.linear(1000)
1515

1616
let delay = strategy({ attempt: 0, error: new Error('test') }, defaultRetryConfig)
@@ -26,7 +26,7 @@ test('linear', async () => {
2626
expect(delay).eq(3000)
2727
})
2828

29-
test('exponential', async () => {
29+
test('applies exponential backoff strategy', async () => {
3030
let strategy = strategies.exponential(1000)
3131

3232
let delay = strategy({ attempt: 0, error: new Error('test') }, defaultRetryConfig)
@@ -39,7 +39,7 @@ test('exponential', async () => {
3939
expect(delay).eq(4000)
4040
})
4141

42-
test('jitter', async () => {
42+
test('applies jitter to delay strategy', async () => {
4343
let strategy = strategies.jitter(10)
4444

4545
let delay = strategy({ attempt: 0, error: new Error('test') }, defaultRetryConfig)
@@ -52,7 +52,7 @@ test('jitter', async () => {
5252
expect(delay3 <= 30).eq(true)
5353
})
5454

55-
test('random', async () => {
55+
test('applies random delay strategy', async () => {
5656
let strategy = strategies.random(10, 20)
5757

5858
let delay = strategy({ attempt: 0, error: new Error('test') }, defaultRetryConfig)
@@ -65,7 +65,7 @@ test('random', async () => {
6565
expect(delay >= 10 && delay <= 20).eq(true)
6666
})
6767

68-
test('backoff', async () => {
68+
test('applies backoff delay strategy', async () => {
6969
let strategy = strategies.backoff(1000, 10000)
7070

7171
let delay = strategy({ attempt: 0, error: new Error('test') }, defaultRetryConfig)
@@ -84,7 +84,7 @@ test('backoff', async () => {
8484
expect(delay).eq(10000)
8585
})
8686

87-
test('combine', async () => {
87+
test('combines multiple strategies', async () => {
8888
let strategy = strategies.combine(strategies.exponential(1000), strategies.jitter(10))
8989

9090
let delay = strategy({ attempt: 0, error: new Error('test') }, defaultRetryConfig)
@@ -97,7 +97,7 @@ test('combine', async () => {
9797
expect(delay >= 4000 && delay <= 4030).eq(true)
9898
})
9999

100-
test('compose', async () => {
100+
test('composes strategy functions', async () => {
101101
let strategy = strategies.compose(strategies.exponential(1000), strategies.jitter(10))
102102

103103
let delay = strategy({ attempt: 0, error: new Error('test') }, defaultRetryConfig)

packages/value/src/list.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { test } from 'vitest'
33
import { List } from '../dist/esm/list.js'
44
import { Uint32 } from '../dist/esm/primitive.js'
55

6-
test('empty list', async (t) => {
6+
test('creates empty list', async (t) => {
77
let list = new List()
88

99
t.expect(list).toMatchInlineSnapshot(`
@@ -16,7 +16,7 @@ test('empty list', async (t) => {
1616
`)
1717
})
1818

19-
test('list of values', async (t) => {
19+
test('creates list of values', async (t) => {
2020
let list = new List(new Uint32(1), new Uint32(2))
2121

2222
t.expect(list).toMatchInlineSnapshot(`

0 commit comments

Comments
 (0)