Skip to content

Commit df823fa

Browse files
committed
feat(subscriptionmarbleassert): implement subscriptionMarbleAssert
1 parent 2d3f7a6 commit df823fa

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/assert/marbleAssert.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';
12
import { SubscriptionLog } from 'rxjs/testing/SubscriptionLog';
23
import { TestMessage } from '../message/TestMessage';
34
import { constructSubscriptionMarble } from './constructSubscriptionMarble';
@@ -14,8 +15,19 @@ const subscriptionMarbleAssert = (source: SubscriptionLog) => (expected: Subscri
1415
const sourceMarble = constructSubscriptionMarble(source);
1516
const expectedMarble = constructSubscriptionMarble(expected);
1617

17-
if (sourceMarble !== expectedMarble) {
18-
throw new Error('unmatch!');
18+
if (
19+
sourceMarble.marbleString !== expectedMarble.marbleString ||
20+
sourceMarble.frameString !== expectedMarble.frameString
21+
) {
22+
const description = `${matcherHint(' to equal ', JSON.stringify(source), JSON.stringify(expected))}
23+
24+
${printReceived(`Source: ${sourceMarble.marbleString}`)}
25+
${printReceived(` ${sourceMarble.frameString}`)}
26+
${printExpected(`Expected: ${expectedMarble.marbleString}`)}
27+
${printExpected(` ${expectedMarble.frameString}`)}
28+
`;
29+
30+
throw new Error(description);
1931
}
2032
};
2133

0 commit comments

Comments
 (0)