1- import { afterEach , describe , expect , it , vi } from "vitest" ;
1+ import { execa } from 'execa' ;
2+ import { afterEach , describe , expect , it , vi } from 'vitest' ;
23
4+ import { capitalize , createClientName , gitCommit } from '../common.js' ;
35import { getClientsConfigField } from '../config.js' ;
46
57vi . mock ( 'execa' , ( ) => {
@@ -9,11 +11,6 @@ vi.mock('execa', () => {
911 } ;
1012} ) ;
1113
12- const { capitalize, createClientName, gitCommit } = await import (
13- '../common.js'
14- ) ;
15- const { execa } = await import ( 'execa' ) ;
16-
1714describe ( 'gitCommit' , ( ) => {
1815 afterEach ( ( ) => {
1916 vi . clearAllMocks ( ) ;
@@ -22,10 +19,7 @@ describe('gitCommit', () => {
2219 it ( 'commits with message' , ( ) => {
2320 gitCommit ( { message : 'chore: does something' } ) ;
2421 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 ) } ) ;
2923 } ) ;
3024
3125 it ( 'commits with co-author' , ( ) => {
@@ -50,8 +44,13 @@ describe('gitCommit', () => {
5044 } ) ;
5145 expect ( execa ) . toHaveBeenCalledTimes ( 1 ) ;
5246 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 ) } ,
5554 ) ;
5655 } ) ;
5756} ) ;
@@ -61,15 +60,11 @@ describe('config', () => {
6160 it ( 'throws if the field is not found' , ( ) => {
6261 expect ( ( ) => {
6362 getClientsConfigField ( 'javascript' , 'foofoo' ) ;
64- } ) . toThrowErrorMatchingInlineSnapshot (
65- `[Error: Unable to find 'foofoo' for 'javascript']`
66- ) ;
63+ } ) . toThrowErrorMatchingInlineSnapshot ( `[Error: Unable to find 'foofoo' for 'javascript']` ) ;
6764 } ) ;
6865
6966 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' ) ;
7368 } ) ;
7469 } ) ;
7570} ) ;
@@ -95,20 +90,14 @@ describe('utils', () => {
9590 describe ( 'createClientName' , ( ) => {
9691 it ( 'does not capitalize every part for JavaScript' , ( ) => {
9792 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' ) ;
10495 } ) ;
10596
10697 it ( 'capitalize every part for other languages' , ( ) => {
10798 expect ( createClientName ( 'search' , 'java' ) ) . toEqual ( 'Search' ) ;
10899 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' ) ;
112101 } ) ;
113102 } ) ;
114103} ) ;
0 commit comments