Skip to content

Commit 23b5397

Browse files
committed
Fix tests
1 parent a8f184c commit 23b5397

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

transforms/ember-object/test.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,27 @@ function runTest(
101101
expectedError: string | undefined,
102102
skipped: boolean
103103
): void {
104+
let error: unknown = null;
105+
let result: string | null | undefined;
106+
107+
try {
108+
result = runTransform(input, testPath);
109+
} catch (e: unknown) {
110+
error = e;
111+
}
112+
104113
if (expectedError) {
105-
// IDG why expect().toThrow() doesn't work here but whatever
106-
let errorCount = 0;
107-
try {
108-
runTransform(input, testPath);
109-
} catch (e: unknown) {
110-
errorCount++;
111-
assert(e instanceof Error, 'expected e to be an Error');
112-
expect(`${e.name}: ${squish(e.message)}`).toEqual(squish(expectedError));
113-
}
114-
expect(errorCount).toEqual(1);
114+
expect(result).toBeUndefined();
115+
assert(error instanceof Error, 'expected e to be an Error');
116+
expect(`${error.name}: ${squish(error.message)}`).toEqual(
117+
squish(expectedError)
118+
);
115119
} else if (skipped) {
116-
expect(runTransform(input, testPath)).toBeUndefined();
120+
expect(error).toBeNull();
121+
expect(result).toEqual(''); // applyTransform coerces undefined to ''
117122
} else {
118-
expect(runTransform(input, testPath)).toEqual(output.trim());
123+
expect(error).toBeNull();
124+
expect(result).toEqual(output.trim());
119125
}
120126
}
121127

0 commit comments

Comments
 (0)