@@ -57,9 +57,17 @@ export async function copyFileToTempDir(fileToCopyPath) {
57
57
return copyFileToDir ( fileToCopyPath , tempFixtureDir )
58
58
}
59
59
60
- async function getNotification ( expectedMessage ) {
61
- return new Promise ( ( resolve ) => {
60
+ /**
61
+ * @param {string } expectedMessage
62
+ * @returns {Promise<import("atom").Notification> }
63
+ */
64
+ function getNotification ( expectedMessage ) {
65
+ return new Promise ( ( resolve , reject ) => {
66
+ /** @type {import("atom").Disposable | undefined } */
62
67
let notificationSub
68
+ /**
69
+ * @param {Promise<import("atom").Notification> } notification
70
+ */
63
71
const newNotification = ( notification ) => {
64
72
if ( notification . getMessage ( ) !== expectedMessage ) {
65
73
// As the specs execute asynchronously, it's possible a notification
@@ -68,8 +76,12 @@ async function getNotification(expectedMessage) {
68
76
return
69
77
}
70
78
// Dispose of the notification subscription
71
- notificationSub . dispose ( )
72
- resolve ( notification )
79
+ if ( notificationSub !== undefined ) {
80
+ notificationSub . dispose ( )
81
+ resolve ( notification )
82
+ } else {
83
+ reject ( )
84
+ }
73
85
}
74
86
// Subscribe to Atom's notifications
75
87
notificationSub = atom . notifications . onDidAddNotification ( newNotification )
@@ -81,6 +93,7 @@ async function getNotification(expectedMessage) {
81
93
* @returns {Promise<void> }
82
94
*/
83
95
async function makeFixes ( textEditor ) {
96
+ /** @type {Promise<void> } */
84
97
const editorReloadPromise = new Promise ( ( resolve ) => {
85
98
// Subscribe to file reload events
86
99
const editorReloadSubscription = textEditor . getBuffer ( ) . onDidReload ( ( ) => {
0 commit comments