@@ -102,6 +102,12 @@ describe("Messages", function () {
102
102
} ) ;
103
103
104
104
describe ( "about call order" , function ( ) {
105
+ function calledRegex ( func , criteria , otherFunc ) {
106
+ return new RegExp (
107
+ "expected " + func . displayName + " to " + criteria +
108
+ " (function " + otherFunc . displayName + "\\(\\) \\{\\}|\\[Function\\])"
109
+ ) ;
110
+ }
105
111
it ( "should be correct for the base cases" , function ( ) {
106
112
var spyA = sinon . spy ( ) ;
107
113
var spyB = sinon . spy ( ) ;
@@ -111,22 +117,22 @@ describe("Messages", function () {
111
117
112
118
expect ( function ( ) {
113
119
spyA . should . have . been . calledBefore ( spyB ) ;
114
- } ) . to . throw ( "expected spyA to have been called before function spyB() {}" ) ;
120
+ } ) . to . throw ( calledRegex ( spyA , " have been called before" , spyB ) ) ;
115
121
116
122
if ( spyA . calledImmediatelyBefore ) {
117
123
expect ( function ( ) {
118
124
spyA . should . have . been . calledImmediatelyBefore ( spyB ) ;
119
- } ) . to . throw ( "expected spyA to have been called immediately before function spyB() {}" ) ;
125
+ } ) . to . throw ( calledRegex ( spyA , " have been called immediately before" , spyB ) ) ;
120
126
}
121
127
122
128
expect ( function ( ) {
123
129
spyB . should . have . been . calledAfter ( spyA ) ;
124
- } ) . to . throw ( "expected spyB to have been called after function spyA() {}" ) ;
130
+ } ) . to . throw ( calledRegex ( spyB , " have been called after" , spyA ) ) ;
125
131
126
132
if ( spyB . calledImmediatelyAfter ) {
127
133
expect ( function ( ) {
128
134
spyB . should . have . been . calledImmediatelyAfter ( spyA ) ;
129
- } ) . to . throw ( "expected spyB to have been called immediately after function spyA() {}" ) ;
135
+ } ) . to . throw ( calledRegex ( spyB , " have been called immediately after" , spyA ) ) ;
130
136
}
131
137
} ) ;
132
138
@@ -142,22 +148,22 @@ describe("Messages", function () {
142
148
143
149
expect ( function ( ) {
144
150
spyA . should . not . have . been . calledBefore ( spyB ) ;
145
- } ) . to . throw ( "expected spyA to not have been called before function spyB() {}" ) ;
151
+ } ) . to . throw ( calledRegex ( spyA , " not have been called before" , spyB ) ) ;
146
152
147
153
if ( spyA . calledImmediatelyBefore ) {
148
154
expect ( function ( ) {
149
155
spyA . should . not . have . been . calledImmediatelyBefore ( spyB ) ;
150
- } ) . to . throw ( "expected spyA to not have been called immediately before function spyB() {}" ) ;
156
+ } ) . to . throw ( calledRegex ( spyA , " not have been called immediately before" , spyB ) ) ;
151
157
}
152
158
153
159
expect ( function ( ) {
154
160
spyB . should . not . have . been . calledAfter ( spyA ) ;
155
- } ) . to . throw ( "expected spyB to not have been called after function spyA() {}" ) ;
161
+ } ) . to . throw ( calledRegex ( spyB , " not have been called after" , spyA ) ) ;
156
162
157
163
if ( spyB . calledImmediatelyAfter ) {
158
164
expect ( function ( ) {
159
165
spyB . should . not . have . been . calledImmediatelyAfter ( spyA ) ;
160
- } ) . to . throw ( "expected spyB to not have been called immediately after function spyA() {}" ) ;
166
+ } ) . to . throw ( calledRegex ( spyB , " not have been called immediately after" , spyA ) ) ;
161
167
}
162
168
} ) ;
163
169
} ) ;
0 commit comments