@@ -4,7 +4,7 @@ import { createDocumentEdits } from '../../../src/fmt/lsp/server.ts';
44test ( 'maps the edit onto the formatted document' , async ( ) => {
55 const edits = await createDocumentEdits (
66 ( ) => 'const a = 1;\nconst b=2;\n' ,
7- async ( ) => 'const a = 1;\nconst b = 2;\n' ,
7+ ( ) => Promise . resolve ( 'const a = 1;\nconst b = 2;\n' ) ,
88 ) ;
99
1010 expect ( edits ) . toEqual ( [
@@ -18,15 +18,15 @@ test('maps the edit onto the formatted document', async () => {
1818test ( 'returns no edits for an already formatted document' , async ( ) => {
1919 const getText = ( ) => 'const a = 1;\n' ;
2020
21- expect ( await createDocumentEdits ( getText , async ( ) => 'const a = 1;\n' ) ) . toEqual ( [ ] ) ;
22- expect ( await createDocumentEdits ( getText , async ( ) => undefined ) ) . toEqual ( [ ] ) ;
21+ expect ( await createDocumentEdits ( getText , ( ) => Promise . resolve ( 'const a = 1;\n' ) ) ) . toEqual ( [ ] ) ;
22+ expect ( await createDocumentEdits ( getText , ( ) => Promise . resolve ( undefined ) ) ) . toEqual ( [ ] ) ;
2323} ) ;
2424
2525test ( 'returns no edits for a document that is not open' , async ( ) => {
2626 expect (
2727 await createDocumentEdits (
2828 ( ) => undefined ,
29- async ( ) => '' ,
29+ ( ) => Promise . resolve ( '' ) ,
3030 ) ,
3131 ) . toEqual ( [ ] ) ;
3232} ) ;
@@ -38,10 +38,10 @@ test('returns no edits when the document changes while it is formatted', async (
3838
3939 const edits = await createDocumentEdits (
4040 ( ) => text ,
41- async ( source ) => {
41+ ( source ) => {
4242 text = 'const b=2;\n' ;
4343
44- return source . replace ( 'const b=2;' , 'const b = 2;' ) ;
44+ return Promise . resolve ( source . replace ( 'const b=2;' , 'const b = 2;' ) ) ;
4545 } ,
4646 ) ;
4747
0 commit comments