@@ -65,7 +65,7 @@ class Expect {
65
65
toContain (expected) => unit.expect (actual, unit.contains (expected));
66
66
toBe (expected) => unit.expect (actual,
67
67
unit.predicate ((actual) => identical (expected, actual), '$expected ' ));
68
- toThrow ([exception]) => unit.expect (actual, exception == null ? unit.throws : unit.throwsA (unit. contains (exception)));
68
+ toThrow ([exception]) => unit.expect (actual, exception == null ? unit.throws : unit.throwsA (new ExceptionContains (exception)));
69
69
toBeFalsy () => unit.expect (actual, (v) => v == null ? true : v is bool ? v == false : ! (v is Object ));
70
70
toBeTruthy () => unit.expect (actual, (v) => v is bool ? v == true : v is Object );
71
71
toBeDefined () => unit.expect (actual, (v) => v is Object );
@@ -91,6 +91,29 @@ class NotExpect {
91
91
unit.predicate ((actual) => ! identical (expected, actual), '$expected ' ));
92
92
}
93
93
94
+ class ExceptionContains extends unit.BaseMatcher {
95
+
96
+ final _expected;
97
+
98
+ const ExceptionContains (this ._expected);
99
+
100
+ bool matches (item, Map matchState) {
101
+ if (item is String ) {
102
+ return item.indexOf (_expected) >= 0 ;
103
+ }
104
+ return matches ('$item ' , matchState);
105
+ }
106
+
107
+ unit.Description describe (unit.Description description) =>
108
+ description.add ('exception contains ' ).addDescriptionOf (_expected);
109
+
110
+ unit.Description describeMismatch (item, unit.Description mismatchDescription,
111
+ Map matchState, bool verbose) {
112
+ return super .describeMismatch ('$item ' , mismatchDescription, matchState,
113
+ verbose);
114
+ }
115
+ }
116
+
94
117
$(selector) {
95
118
return new JQuery (selector);
96
119
}
0 commit comments