konacha-chai-matchers 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,101 @@
1
+ (function() {
2
+
3
+ (function(chaiBackbone) {
4
+ if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
5
+ return module.exports = chaiBackbone;
6
+ } else if (typeof define === "function" && define.amd) {
7
+ return define(function() {
8
+ return chaiBackbone;
9
+ });
10
+ } else {
11
+ return chai.use(chaiBackbone);
12
+ }
13
+ })(function(chai, utils) {
14
+ var flag, inspect, routeTo;
15
+ inspect = utils.inspect;
16
+ flag = utils.flag;
17
+ chai.Assertion.addMethod('trigger', function(trigger, options) {
18
+ var definedActions;
19
+ if (options == null) options = {};
20
+ definedActions = flag(this, 'whenActions') || [];
21
+ definedActions.push({
22
+ negate: flag(this, 'negate'),
23
+ before: function(context) {
24
+ this.callback = sinon.spy();
25
+ return flag(context, 'object').on(trigger, this.callback);
26
+ },
27
+ after: function(context) {
28
+ var negate, _ref;
29
+ negate = flag(context, 'negate');
30
+ flag(context, 'negate', this.negate);
31
+ context.assert(this.callback.calledOnce, "expected to trigger " + trigger, "expected not to trigger " + trigger);
32
+ if (options["with"] != null) {
33
+ context.assert((_ref = this.callback).calledWith.apply(_ref, options["with"]), "expected trigger to be called with " + (inspect(options["with"])) + ", but was called with " + (inspect(this.callback.args[0])) + ".", "expected trigger not to be called with " + (inspect(options["with"])) + ", but was");
34
+ }
35
+ return flag(context, 'negate', negate);
36
+ }
37
+ });
38
+ return flag(this, 'whenActions', definedActions);
39
+ });
40
+ chai.Assertion.addProperty('route', function() {
41
+ return flag(this, 'routing', true);
42
+ });
43
+ routeTo = function(router, methodName, options) {
44
+ var consideredRouter, current_history, route, spy, _i, _len, _ref;
45
+ if (options == null) options = {};
46
+ current_history = Backbone.history;
47
+ Backbone.history = new Backbone.History;
48
+ spy = sinon.spy(router, methodName);
49
+ this.assert(router._bindRoutes != null, 'provided router is not a Backbone.Router');
50
+ router._bindRoutes();
51
+ if (options.considering != null) {
52
+ _ref = options.considering;
53
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
54
+ consideredRouter = _ref[_i];
55
+ consideredRouter._bindRoutes();
56
+ }
57
+ }
58
+ Backbone.history.options = {
59
+ root: '/'
60
+ };
61
+ route = flag(this, 'object');
62
+ Backbone.history.loadUrl(route);
63
+ Backbone.history = current_history;
64
+ router[methodName].restore();
65
+ this.assert(spy.calledOnce, "expected `" + route + "` to route to " + methodName, "expected `" + route + "` not to route to " + methodName);
66
+ if (options.arguments != null) {
67
+ return this.assert(spy.calledWith.apply(spy, options.arguments), "expected `" + methodName + "` to be called with " + (inspect(options.arguments)) + ", but was called with " + (inspect(spy.args[0])) + " instead", "expected `" + methodName + "` not to be called with " + (inspect(options.arguments)) + ", but was");
68
+ }
69
+ };
70
+ chai.Assertion.overwriteProperty('to', function(_super) {
71
+ return function() {
72
+ if (flag(this, 'routing')) {
73
+ return routeTo;
74
+ } else {
75
+ return _super.apply(this, arguments);
76
+ }
77
+ };
78
+ });
79
+ return chai.Assertion.addMethod('call', function(methodName) {
80
+ var definedActions, object;
81
+ object = flag(this, 'object');
82
+ definedActions = flag(this, 'whenActions') || [];
83
+ definedActions.push({
84
+ negate: flag(this, 'negate'),
85
+ before: function(context) {
86
+ this.originalMethod = object[methodName];
87
+ this.spy = sinon.spy();
88
+ object[methodName] = this.spy;
89
+ return typeof object.delegateEvents === "function" ? object.delegateEvents() : void 0;
90
+ },
91
+ after: function(context) {
92
+ object[methodName] = this.originalMethod;
93
+ if (typeof object.delegateEvents === "function") object.delegateEvents();
94
+ return context.assert(this.spy.callCount > 0, this.spy.printf("expected %n to have been called at least once"), this.spy.printf("expected %n to not have been called"));
95
+ }
96
+ });
97
+ return flag(this, 'whenActions', definedActions);
98
+ });
99
+ });
100
+
101
+ }).call(this);
@@ -0,0 +1,173 @@
1
+ (function(chaiChanges) {
2
+ if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
3
+ return module.exports = chaiChanges;
4
+ } else if (typeof define === "function" && define.amd) {
5
+ return define(function() {
6
+ return chaiChanges;
7
+ });
8
+ } else {
9
+ return chai.use(chaiChanges);
10
+ }
11
+ })(function(chai, utils) {
12
+ var changeBy, changeByAssert, changeFrom, changeFromAssert, changeFromBeginAssert, changeTo, changeToAssert, changeToBeginAssert, flag, formatFunction, inspect, noChangeAssert;
13
+ inspect = utils.inspect;
14
+ flag = utils.flag;
15
+ /*
16
+ #
17
+ # Changes Matchers
18
+ #
19
+ */
20
+
21
+ chai.Assertion.addMethod('when', function(val) {
22
+ var action, definedActions, _i, _j, _len, _len1, _results;
23
+ definedActions = flag(this, 'whenActions') || [];
24
+ for (_i = 0, _len = definedActions.length; _i < _len; _i++) {
25
+ action = definedActions[_i];
26
+ if (typeof action.before === "function") {
27
+ action.before(this);
28
+ }
29
+ }
30
+ val();
31
+ _results = [];
32
+ for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) {
33
+ action = definedActions[_j];
34
+ _results.push(typeof action.after === "function" ? action.after(this) : void 0);
35
+ }
36
+ return _results;
37
+ });
38
+ noChangeAssert = function(context) {
39
+ var endValue, negate, object, relevant, result, startValue;
40
+ relevant = flag(context, 'no-change');
41
+ if (!relevant) {
42
+ return;
43
+ }
44
+ negate = flag(context, 'negate');
45
+ flag(context, 'negate', this.negate);
46
+ object = flag(context, 'object');
47
+ startValue = flag(context, 'changeStart');
48
+ endValue = object();
49
+ result = !utils.eql(endValue, startValue);
50
+ context.assert(result, "expected `" + (formatFunction(object)) + "` to change, but it stayed " + (utils.inspect(startValue)), "expected `" + (formatFunction(object)) + "` not to change, but it changed from " + (utils.inspect(startValue)) + " to " + (utils.inspect(endValue)));
51
+ return flag(context, 'negate', negate);
52
+ };
53
+ changeByAssert = function(context) {
54
+ var actualDelta, endValue, negate, object, startValue;
55
+ negate = flag(context, 'negate');
56
+ flag(context, 'negate', this.negate);
57
+ object = flag(context, 'object');
58
+ startValue = flag(context, 'changeStart');
59
+ endValue = object();
60
+ actualDelta = endValue - startValue;
61
+ context.assert(this.expectedDelta === actualDelta, "expected `" + (formatFunction(object)) + "` to change by " + this.expectedDelta + ", but it changed by " + actualDelta, "expected `" + (formatFunction(object)) + "` not to change by " + this.expectedDelta + ", but it did");
62
+ return flag(context, 'negate', negate);
63
+ };
64
+ changeToBeginAssert = function(context) {
65
+ var negate, object, result, startValue;
66
+ negate = flag(context, 'negate');
67
+ flag(context, 'negate', this.negate);
68
+ object = flag(context, 'object');
69
+ startValue = object();
70
+ result = !utils.eql(startValue, this.expectedEndValue);
71
+ if (negate) {
72
+ result = !result;
73
+ }
74
+ context.assert(result, "expected `" + (formatFunction(object)) + "` to change to " + (utils.inspect(this.expectedEndValue)) + ", but it was already " + (utils.inspect(startValue)), "not supported");
75
+ return flag(context, 'negate', negate);
76
+ };
77
+ changeToAssert = function(context) {
78
+ var endValue, negate, object, result;
79
+ negate = flag(context, 'negate');
80
+ flag(context, 'negate', this.negate);
81
+ object = flag(context, 'object');
82
+ endValue = object();
83
+ result = utils.eql(endValue, this.expectedEndValue);
84
+ context.assert(result, "expected `" + (formatFunction(object)) + "` to change to " + (utils.inspect(this.expectedEndValue)) + ", but it changed to " + (utils.inspect(endValue)), "expected `" + (formatFunction(object)) + "` not to change to " + (utils.inspect(this.expectedEndValue)) + ", but it did");
85
+ return flag(context, 'negate', negate);
86
+ };
87
+ changeFromBeginAssert = function(context) {
88
+ var negate, object, result, startValue;
89
+ negate = flag(context, 'negate');
90
+ flag(context, 'negate', this.negate);
91
+ object = flag(context, 'object');
92
+ startValue = object();
93
+ result = utils.eql(startValue, this.expectedStartValue);
94
+ context.assert(result, "expected the change of `" + (formatFunction(object)) + "` to start from " + (utils.inspect(this.expectedStartValue)) + ", but it started from " + (utils.inspect(startValue)), "expected the change of `" + (formatFunction(object)) + "` not to start from " + (utils.inspect(this.expectedStartValue)) + ", but it did");
95
+ return flag(context, 'negate', negate);
96
+ };
97
+ changeFromAssert = function(context) {
98
+ var endValue, negate, object, result, startValue;
99
+ negate = flag(context, 'negate');
100
+ flag(context, 'negate', this.negate);
101
+ object = flag(context, 'object');
102
+ startValue = flag(context, 'changeStart');
103
+ endValue = object();
104
+ result = !utils.eql(startValue, endValue);
105
+ if (negate) {
106
+ result = !result;
107
+ }
108
+ context.assert(result, "expected `" + (formatFunction(object)) + "` to change from " + (utils.inspect(this.expectedStartValue)) + ", but it did not change", "not supported");
109
+ return flag(context, 'negate', negate);
110
+ };
111
+ chai.Assertion.addProperty('change', function() {
112
+ var definedActions;
113
+ flag(this, 'no-change', true);
114
+ definedActions = flag(this, 'whenActions') || [];
115
+ definedActions.push({
116
+ negate: flag(this, 'negate'),
117
+ before: function(context) {
118
+ var startValue;
119
+ startValue = flag(context, 'object')();
120
+ return flag(context, 'changeStart', startValue);
121
+ },
122
+ after: noChangeAssert
123
+ });
124
+ return flag(this, 'whenActions', definedActions);
125
+ });
126
+ formatFunction = function(func) {
127
+ return func.toString().replace(/^\s*function \(\) {\s*/, '').replace(/\s+}$/, '').replace(/\s*return\s*/, '');
128
+ };
129
+ changeBy = function(delta) {
130
+ var definedActions;
131
+ flag(this, 'no-change', false);
132
+ definedActions = flag(this, 'whenActions') || [];
133
+ definedActions.push({
134
+ negate: flag(this, 'negate'),
135
+ expectedDelta: delta,
136
+ after: changeByAssert
137
+ });
138
+ return flag(this, 'whenActions', definedActions);
139
+ };
140
+ chai.Assertion.addChainableMethod('by', changeBy, function() {
141
+ return this;
142
+ });
143
+ changeTo = function(endValue) {
144
+ var definedActions;
145
+ flag(this, 'no-change', false);
146
+ definedActions = flag(this, 'whenActions') || [];
147
+ definedActions.push({
148
+ negate: flag(this, 'negate'),
149
+ expectedEndValue: endValue,
150
+ before: changeToBeginAssert,
151
+ after: changeToAssert
152
+ });
153
+ return flag(this, 'whenActions', definedActions);
154
+ };
155
+ chai.Assertion.addChainableMethod('to', changeTo, function() {
156
+ return this;
157
+ });
158
+ changeFrom = function(startValue) {
159
+ var definedActions;
160
+ flag(this, 'no-change', false);
161
+ definedActions = flag(this, 'whenActions') || [];
162
+ definedActions.push({
163
+ negate: flag(this, 'negate'),
164
+ expectedStartValue: startValue,
165
+ before: changeFromBeginAssert,
166
+ after: changeFromAssert
167
+ });
168
+ return flag(this, 'whenActions', definedActions);
169
+ };
170
+ return chai.Assertion.addChainableMethod('from', changeFrom, function() {
171
+ return this;
172
+ });
173
+ });
@@ -0,0 +1,166 @@
1
+ !function (name, definition) {
2
+ if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
3
+ else this[name] = definition();
4
+ }('chai_factories', function () {
5
+ // CommonJS require()
6
+ function require(p){
7
+ var path = require.resolve(p)
8
+ , mod = require.modules[path];
9
+ if (!mod) throw new Error('failed to require "' + p + '"');
10
+ if (!mod.exports) {
11
+ mod.exports = {};
12
+ mod.call(mod.exports, mod, mod.exports, require.relative(path));
13
+ }
14
+ return mod.exports;
15
+ }
16
+
17
+ require.modules = {};
18
+
19
+ require.resolve = function (path){
20
+ var orig = path
21
+ , reg = path + '.js'
22
+ , index = path + '/index.js';
23
+ return require.modules[reg] && reg
24
+ || require.modules[index] && index
25
+ || orig;
26
+ };
27
+
28
+ require.register = function (path, fn){
29
+ require.modules[path] = fn;
30
+ };
31
+
32
+ require.relative = function (parent) {
33
+ return function(p){
34
+ if ('.' != p[0]) return require(p);
35
+
36
+ var path = parent.split('/')
37
+ , segs = p.split('/');
38
+ path.pop();
39
+
40
+ for (var i = 0; i < segs.length; i++) {
41
+ var seg = segs[i];
42
+ if ('..' == seg) path.pop();
43
+ else if ('.' != seg) path.push(seg);
44
+ }
45
+
46
+ return require(path.join('/'));
47
+ };
48
+ };
49
+
50
+
51
+ require.register("factories", function (module, exports, require) {
52
+ /*!
53
+ * chai-null :: Factories over fixtures
54
+ *
55
+ * Chai.js Team - http://chaijs.com/
56
+ * Copyright (c) 2012 Veselin Todorov <hi@vesln.com>
57
+ *
58
+ * MIT Licensed
59
+ */
60
+
61
+ /**
62
+ * Extends multiple objects.
63
+ *
64
+ * @returns {Object}
65
+ */
66
+ function extend() {
67
+ var arr = Array.prototype.slice.call(arguments);
68
+ var main = arr.length === 2 ? arr.shift() : {};
69
+
70
+ arr.forEach(function(obj) {
71
+ for (var p in obj) {
72
+ if (!obj.hasOwnProperty(p)) continue;
73
+ main[p] = obj[p];
74
+ }
75
+ });
76
+
77
+ return main;
78
+ };
79
+
80
+ /**
81
+ * Collector. Store the registered factories.
82
+ *
83
+ * @api public
84
+ */
85
+ function Collector() {
86
+ this.collection = {};
87
+ };
88
+
89
+ /**
90
+ * Register a factory.
91
+ *
92
+ * @param {String} name
93
+ * @param {Factory} factory
94
+ * @api public
95
+ */
96
+ Collector.prototype.set = function(name, factory) {
97
+ this.collection[name] = factory;
98
+ };
99
+
100
+ /**
101
+ * Get a factory.
102
+ *
103
+ * @param {String} name
104
+ * @returns {Factory} factory
105
+ * @api public
106
+ */
107
+ Collector.prototype.get = function(name) {
108
+ return this.collection[name];
109
+ };
110
+
111
+ /**
112
+ * Factory class.
113
+ *
114
+ * @param {Object} attributes
115
+ * @api public
116
+ */
117
+ function Factory(attributes) {
118
+ this.attributes = attributes;
119
+ };
120
+
121
+ /**
122
+ * Create a factory.
123
+ *
124
+ * @param {Object} attributes
125
+ * @returns {Object}
126
+ * @api public
127
+ */
128
+ Factory.prototype.create = function(attributes) {
129
+ return extend(extend(this.attributes), attributes);
130
+ };
131
+
132
+ /**
133
+ * Extend a factory.
134
+ *
135
+ * @param {Object} attributes
136
+ * @returns {Object}
137
+ * @api public
138
+ */
139
+ Factory.prototype.extend = function(attributes) {
140
+ return this.create(attributes);
141
+ };
142
+
143
+ /**
144
+ * Register as plugin.
145
+ */
146
+ module.exports = function(chai, _) {
147
+ var collector = new Collector;
148
+
149
+ chai.factory = function(name, attributes) {
150
+ var factory = new Factory(attributes);
151
+ collector.set(name, factory);
152
+ return factory;
153
+ };
154
+
155
+ chai.create = function(name, attributes) {
156
+ var factory = collector.get(name);
157
+ if (!factory) throw new Error('Unknown factory: ' + name);
158
+ return factory.create(attributes);
159
+ };
160
+ };
161
+
162
+ }); // module factories
163
+ return require('factories');
164
+ });
165
+
166
+ chai.use(chai_factories);
@@ -0,0 +1,232 @@
1
+ (function (chaiJquery) {
2
+ // Module systems magic dance.
3
+ if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
4
+ // NodeJS
5
+ module.exports = chaiJquery;
6
+ } else if (typeof define === "function" && define.amd) {
7
+ // AMD
8
+ define(function () {
9
+ return chaiJquery;
10
+ });
11
+ } else {
12
+ // Other environment (usually <script> tag): plug in to global chai instance directly.
13
+ chai.use(chaiJquery);
14
+ }
15
+ }(function (chai, utils) {
16
+ var inspect = utils.inspect,
17
+ flag = utils.flag;
18
+
19
+ jQuery.fn.inspect = function (depth) {
20
+ var el = jQuery('<div />').append(this.clone());
21
+ if (depth !== undefined) {
22
+ var children = el.children();
23
+ while (depth-- > 0)
24
+ children = children.children();
25
+ children.html('...');
26
+ }
27
+ return el.html();
28
+ };
29
+
30
+ var props = {attr: 'attribute', css: 'CSS property'};
31
+ for (var prop in props) {
32
+ (function (prop, description) {
33
+ chai.Assertion.addMethod(prop, function (name, val) {
34
+ var actual = flag(this, 'object')[prop](name);
35
+
36
+ if (!flag(this, 'negate') || undefined === val) {
37
+ this.assert(
38
+ undefined !== actual
39
+ , 'expected #{this} to have a #{exp} ' + description
40
+ , 'expected #{this} not to have a #{exp} ' + description
41
+ , name
42
+ );
43
+ }
44
+
45
+ if (undefined !== val) {
46
+ this.assert(
47
+ val === actual
48
+ , 'expected #{this} to have a ' + inspect(name) + ' ' + description + ' with the value #{exp}, but the value was #{act}'
49
+ , 'expected #{this} not to have a ' + inspect(name) + ' ' + description + ' with the value #{act}'
50
+ , val
51
+ , actual
52
+ );
53
+ }
54
+
55
+ flag(this, 'object', actual);
56
+ });
57
+ })(prop, props[prop]);
58
+ }
59
+
60
+ chai.Assertion.addMethod('data', function (name, val) {
61
+ // Work around a chai bug (https://github.com/logicalparadox/chai/issues/16)
62
+ if (flag(this, 'negate') && undefined !== val && undefined === flag(this, 'object').data(name)) {
63
+ return;
64
+ }
65
+
66
+ var assertion = new chai.Assertion(flag(this, 'object').data());
67
+ if (flag(this, 'negate'))
68
+ assertion = assertion.not;
69
+ return assertion.property(name, val);
70
+ });
71
+
72
+ chai.Assertion.addMethod('class', function (className) {
73
+ this.assert(
74
+ flag(this, 'object').hasClass(className)
75
+ , 'expected #{this} to have class #{exp}'
76
+ , 'expected #{this} not to have class #{exp}'
77
+ , className
78
+ );
79
+ });
80
+
81
+ chai.Assertion.addMethod('id', function (id) {
82
+ this.assert(
83
+ flag(this, 'object').attr('id') === id
84
+ , 'expected #{this} to have id #{exp}'
85
+ , 'expected #{this} not to have id #{exp}'
86
+ , id
87
+ );
88
+ });
89
+
90
+ chai.Assertion.addMethod('html', function (html) {
91
+ this.assert(
92
+ flag(this, 'object').html() === html
93
+ , 'expected #{this} to have HTML #{exp}'
94
+ , 'expected #{this} not to have HTML #{exp}'
95
+ , html
96
+ );
97
+ });
98
+
99
+ chai.Assertion.addMethod('text', function (text) {
100
+ this.assert(
101
+ flag(this, 'object').text() === text
102
+ , 'expected #{this} to have text #{exp}'
103
+ , 'expected #{this} not to have text #{exp}'
104
+ , text
105
+ );
106
+ });
107
+
108
+ chai.Assertion.addMethod('value', function (value) {
109
+ this.assert(
110
+ flag(this, 'object').val() === value
111
+ , 'expected #{this} to have value #{exp}'
112
+ , 'expected #{this} not to have value #{exp}'
113
+ , value
114
+ );
115
+ });
116
+
117
+ jQuery.each(['visible', 'hidden', 'selected', 'checked', 'disabled'], function (i, attr) {
118
+ chai.Assertion.addProperty(attr, function () {
119
+ this.assert(
120
+ flag(this, 'object').is(':' + attr)
121
+ , 'expected #{this} to be ' + attr
122
+ , 'expected #{this} not to be ' + attr);
123
+ });
124
+ });
125
+
126
+ chai.Assertion.overwriteProperty('exist', function (_super) {
127
+ return function () {
128
+ var obj = flag(this, 'object');
129
+ if (obj instanceof jQuery) {
130
+ this.assert(
131
+ obj.length > 0
132
+ , 'expected ' + inspect(obj.selector) + ' to exist'
133
+ , 'expected ' + inspect(obj.selector) + ' not to exist');
134
+ } else {
135
+ _super.apply(this, arguments);
136
+ }
137
+ };
138
+ });
139
+
140
+ chai.Assertion.overwriteProperty('empty', function (_super) {
141
+ return function () {
142
+ var obj = flag(this, 'object');
143
+ if (obj instanceof jQuery) {
144
+ this.assert(
145
+ obj.is(':empty')
146
+ , 'expected #{this} to be empty'
147
+ , 'expected #{this} not to be empty');
148
+ } else {
149
+ _super.apply(this, arguments);
150
+ }
151
+ };
152
+ });
153
+
154
+ chai.Assertion.overwriteProperty('be', function (_super) {
155
+ return function () {
156
+ var be = function (selector) {
157
+ var obj = flag(this, 'object');
158
+ if (obj instanceof jQuery) {
159
+ this.assert(
160
+ obj.is(selector)
161
+ , 'expected #{this} to be #{exp}'
162
+ , 'expected #{this} not to be #{exp}'
163
+ , selector
164
+ );
165
+ } else {
166
+ _super.apply(this, arguments);
167
+ }
168
+ };
169
+ be.__proto__ = this;
170
+ return be;
171
+ }
172
+ });
173
+
174
+ chai.Assertion.overwriteMethod('match', function (_super) {
175
+ return function (selector) {
176
+ var obj = flag(this, 'object');
177
+ if (obj instanceof jQuery) {
178
+ this.assert(
179
+ obj.is(selector)
180
+ , 'expected #{this} to match #{exp}'
181
+ , 'expected #{this} not to match #{exp}'
182
+ , selector
183
+ );
184
+ } else {
185
+ _super.apply(this, arguments);
186
+ }
187
+ }
188
+ });
189
+
190
+ chai.Assertion.overwriteProperty('contain', function (_super) {
191
+ return function () {
192
+ _super.call(this);
193
+ var contain = function (text) {
194
+ var obj = flag(this, 'object');
195
+ if (obj instanceof jQuery) {
196
+ this.assert(
197
+ obj.is(':contains(\'' + text + '\')')
198
+ , 'expected #{this} to contain #{exp}'
199
+ , 'expected #{this} not to contain #{exp}'
200
+ , text
201
+ );
202
+ } else {
203
+ Function.prototype.apply.call(_super.call(this), this, arguments);
204
+ }
205
+ };
206
+ contain.__proto__ = this;
207
+ return contain;
208
+ }
209
+ });
210
+
211
+ chai.Assertion.overwriteProperty('have', function (_super) {
212
+ return function () {
213
+ var obj = flag(this, 'object');
214
+ if (obj instanceof jQuery) {
215
+ var have = function (selector) {
216
+ this.assert(
217
+ // Using find() rather than has() to work around a jQuery bug:
218
+ // http://bugs.jquery.com/ticket/11706
219
+ obj.find(selector).length > 0
220
+ , 'expected #{this} to have #{exp}'
221
+ , 'expected #{this} not to have #{exp}'
222
+ , selector
223
+ );
224
+ };
225
+ have.__proto__ = this;
226
+ return have;
227
+ } else {
228
+ _super.call(this);
229
+ }
230
+ }
231
+ });
232
+ }));