1
+ "use babel"
1
2
import { Range } from 'atom' ;
2
3
import { observeTextEditors } from '@atom-ide-community/nuclide-commons-atom/FileEventHandlers' ;
3
4
import { SAVE_TIMEOUT } from '../dist/CodeFormatManager' ;
4
5
import UniversalDisposable from '@atom-ide-community/nuclide-commons/UniversalDisposable' ;
5
6
import temp from 'temp' ;
6
7
import * as config from '../dist/config' ;
7
8
import CodeFormatManager from '../dist/CodeFormatManager' ;
8
- import waitsFor from '../../../../../jest/waits_for ' ;
9
+ import waitsFor from '@artemv/wait-until-promise ' ;
9
10
10
11
const sleep = n => new Promise ( r => setTimeout ( r , n ) ) ;
11
12
@@ -64,7 +65,7 @@ describe('CodeFormatManager', () => {
64
65
} ) ;
65
66
66
67
it ( 'formats an editor on type' , async ( ) => {
67
- jest . spyOn ( config , 'getFormatOnType' ) . mockReturnValue ( true ) ;
68
+ spyOn ( config , 'getFormatOnType' ) . and . returnValue ( true ) ;
68
69
const provider = {
69
70
grammarScopes : [ 'text.plain.null-grammar' ] ,
70
71
priority : 1 ,
@@ -78,7 +79,7 @@ describe('CodeFormatManager', () => {
78
79
] ) ,
79
80
keepCursorPosition : false ,
80
81
} ;
81
- const spy = jest . spyOn ( provider , 'formatAtPosition' ) ;
82
+ const spy = spyOn ( provider , 'formatAtPosition' ) ;
82
83
manager . addOnTypeProvider ( provider ) ;
83
84
84
85
textEditor . setText ( 'a' ) ;
@@ -92,7 +93,7 @@ describe('CodeFormatManager', () => {
92
93
} ) ;
93
94
94
95
it ( 'formats an editor on save' , async ( ) => {
95
- jest . spyOn ( config , 'getFormatOnSave' ) . mockReturnValue ( true ) ;
96
+ spyOn ( config , 'getFormatOnSave' ) . and . returnValue ( true ) ;
96
97
manager . addOnSaveProvider ( {
97
98
grammarScopes : [ 'text.plain.null-grammar' ] ,
98
99
priority : 1 ,
@@ -112,7 +113,7 @@ describe('CodeFormatManager', () => {
112
113
} ) ;
113
114
114
115
it ( 'should still save on timeout' , async ( ) => {
115
- jest . spyOn ( config , 'getFormatOnSave' ) . mockReturnValue ( true ) ;
116
+ spyOn ( config , 'getFormatOnSave' ) . and . returnValue ( true ) ;
116
117
manager . addRangeProvider ( {
117
118
grammarScopes : [ 'text.plain.null-grammar' ] ,
118
119
priority : 1 ,
@@ -122,7 +123,7 @@ describe('CodeFormatManager', () => {
122
123
} ,
123
124
} ) ;
124
125
125
- const spy = jest . spyOn ( textEditor . getBuffer ( ) , 'save' ) ;
126
+ const spy = spyOn ( textEditor . getBuffer ( ) , 'save' ) ;
126
127
textEditor . save ( ) ;
127
128
128
129
// Wait until the buffer has been saved and verify it has been saved exactly
0 commit comments