1
- import { afterEach , describe , expect , it , vi } from "vitest" ;
1
+ import { execa } from 'execa' ;
2
+ import { afterEach , describe , expect , it , vi } from 'vitest' ;
2
3
4
+ import { capitalize , createClientName , gitCommit } from '../common.js' ;
3
5
import { getClientsConfigField } from '../config.js' ;
4
6
5
7
vi . mock ( 'execa' , ( ) => {
@@ -9,11 +11,6 @@ vi.mock('execa', () => {
9
11
} ;
10
12
} ) ;
11
13
12
- const { capitalize, createClientName, gitCommit } = await import (
13
- '../common.js'
14
- ) ;
15
- const { execa } = await import ( 'execa' ) ;
16
-
17
14
describe ( 'gitCommit' , ( ) => {
18
15
afterEach ( ( ) => {
19
16
vi . clearAllMocks ( ) ;
@@ -22,10 +19,7 @@ describe('gitCommit', () => {
22
19
it ( 'commits with message' , ( ) => {
23
20
gitCommit ( { message : 'chore: does something' } ) ;
24
21
expect ( execa ) . toHaveBeenCalledTimes ( 1 ) ;
25
- expect ( execa ) . toHaveBeenCalledWith (
26
- 'git' , [ "commit" , "-m" , "chore: does something" ] ,
27
- { cwd : expect . any ( String ) }
28
- ) ;
22
+ expect ( execa ) . toHaveBeenCalledWith ( 'git' , [ 'commit' , '-m' , 'chore: does something' ] , { cwd : expect . any ( String ) } ) ;
29
23
} ) ;
30
24
31
25
it ( 'commits with co-author' , ( ) => {
@@ -50,8 +44,13 @@ describe('gitCommit', () => {
50
44
} ) ;
51
45
expect ( execa ) . toHaveBeenCalledTimes ( 1 ) ;
52
46
expect ( execa ) . toHaveBeenCalledWith (
53
- 'git' , [ "commit" , "-m" , "chore: does something\n\n\nCo-authored-by: them <[email protected] >\nCo-authored-by: me <[email protected] >\nCo-authored-by: you <[email protected] >" ] ,
54
- { cwd : expect . any ( String ) }
47
+ 'git' ,
48
+ [
49
+ 'commit' ,
50
+ '-m' ,
51
+ 'chore: does something\n\n\nCo-authored-by: them <[email protected] >\nCo-authored-by: me <[email protected] >\nCo-authored-by: you <[email protected] >' ,
52
+ ] ,
53
+ { cwd : expect . any ( String ) } ,
55
54
) ;
56
55
} ) ;
57
56
} ) ;
@@ -61,15 +60,11 @@ describe('config', () => {
61
60
it ( 'throws if the field is not found' , ( ) => {
62
61
expect ( ( ) => {
63
62
getClientsConfigField ( 'javascript' , 'foofoo' ) ;
64
- } ) . toThrowErrorMatchingInlineSnapshot (
65
- `[Error: Unable to find 'foofoo' for 'javascript']`
66
- ) ;
63
+ } ) . toThrowErrorMatchingInlineSnapshot ( `[Error: Unable to find 'foofoo' for 'javascript']` ) ;
67
64
} ) ;
68
65
69
66
it ( 'find the field if it exists' , ( ) => {
70
- expect ( getClientsConfigField ( 'java' , [ 'tests' , 'extension' ] ) ) . toEqual (
71
- '.test.java'
72
- ) ;
67
+ expect ( getClientsConfigField ( 'java' , [ 'tests' , 'extension' ] ) ) . toEqual ( '.test.java' ) ;
73
68
} ) ;
74
69
} ) ;
75
70
} ) ;
@@ -95,20 +90,14 @@ describe('utils', () => {
95
90
describe ( 'createClientName' , ( ) => {
96
91
it ( 'does not capitalize every part for JavaScript' , ( ) => {
97
92
expect ( createClientName ( 'search' , 'javascript' ) ) . toEqual ( 'search' ) ;
98
- expect ( createClientName ( 'search-client' , 'javascript' ) ) . toEqual (
99
- 'searchClient'
100
- ) ;
101
- expect ( createClientName ( 'search-cli!nt-complex' , 'javascript' ) ) . toEqual (
102
- 'searchCli!ntComplex'
103
- ) ;
93
+ expect ( createClientName ( 'search-client' , 'javascript' ) ) . toEqual ( 'searchClient' ) ;
94
+ expect ( createClientName ( 'search-cli!nt-complex' , 'javascript' ) ) . toEqual ( 'searchCli!ntComplex' ) ;
104
95
} ) ;
105
96
106
97
it ( 'capitalize every part for other languages' , ( ) => {
107
98
expect ( createClientName ( 'search' , 'java' ) ) . toEqual ( 'Search' ) ;
108
99
expect ( createClientName ( 'search-client' , 'java' ) ) . toEqual ( 'SearchClient' ) ;
109
- expect ( createClientName ( 'search-cli!nt-complex' , 'java' ) ) . toEqual (
110
- 'SearchCli!ntComplex'
111
- ) ;
100
+ expect ( createClientName ( 'search-cli!nt-complex' , 'java' ) ) . toEqual ( 'SearchCli!ntComplex' ) ;
112
101
} ) ;
113
102
} ) ;
114
103
} ) ;
0 commit comments