Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit 9113d4a

Browse files
author
Steve Calvert
committed
Bye bye assert, hello expect
1 parent 20f1f71 commit 9113d4a

File tree

4 files changed

+44
-44
lines changed

4 files changed

+44
-44
lines changed

tests/runner/test-main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require(['test-config'], function() {
66
],
77
function(require, chai, mocha) {
88
require(['glob!tests/unit/*.js'], function() {
9-
window.assert = chai.assert;
9+
window.expect = chai.expect;
1010

1111
if (window.mochaPhantomJS) {
1212
return window.mochaPhantomJS.run();

tests/unit/constructor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ define([
2222
it('creates a bellows instance', function() {
2323
var bellows = new Bellows($element);
2424

25-
assert.isDefined(bellows);
25+
expect(bellows).to.be.defined;
2626
});
2727
});
2828
});

tests/unit/options.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,54 @@ define([
2323
it('correctly defines singleItemOpen', function() {
2424
var bellows = new Bellows($element);
2525

26-
assert.isFalse(bellows.options.singleItemOpen);
27-
assert.isBoolean(bellows.options.singleItemOpen);
26+
expect(bellows.options.singleItemOpen).to.be.false;
27+
expect(bellows.options.singleItemOpen).to.be.a('boolean');
2828
});
2929

3030
it('correctly defines duration', function() {
3131
var bellows = new Bellows($element);
3232

33-
assert.equal(bellows.options.duration, 200);
34-
assert.isNumber(bellows.options.duration);
33+
expect(bellows.options.duration).to.equal(200);
34+
expect(bellows.options.duration).to.be.a('number');
3535
});
3636

3737
it('correctly defines easing', function() {
3838
var bellows = new Bellows($element);
3939

40-
assert.equal(bellows.options.easing, 'swing');
41-
assert.isString(bellows.options.easing);
40+
expect(bellows.options.easing).to.equal('swing');
41+
expect(bellows.options.easing).to.be.a('string');
4242
});
4343

4444
it('correctly defines events', function() {
4545
var bellows = new Bellows($element);
4646

47-
assert.isFunction(bellows.options.open);
48-
assert.isFunction(bellows.options.opened);
49-
assert.isFunction(bellows.options.close);
50-
assert.isFunction(bellows.options.closed);
47+
expect(bellows.options.open).to.be.a('function');
48+
expect(bellows.options.opened).to.be.a('function');
49+
expect(bellows.options.close).to.be.a('function');
50+
expect(bellows.options.closed).to.be.a('function');
5151
});
5252
});
5353

5454
describe('creates custom options when options parameter used', function() {
5555
it('correctly defines singleItemOpen as true', function() {
5656
var bellows = new Bellows($element, { singleItemOpen: true });
5757

58-
assert.isTrue(bellows.options.singleItemOpen);
59-
assert.isBoolean(bellows.options.singleItemOpen);
58+
expect(bellows.options.singleItemOpen).to.be.true;
59+
expect(bellows.options.singleItemOpen).to.be.a('boolean');
6060
});
6161

6262
it('correctly defines duration of 400', function() {
6363
var bellows = new Bellows($element, { duration: 400 });
6464

65-
assert.equal(bellows.options.duration, 400);
66-
assert.isNumber(bellows.options.duration);
65+
expect(bellows.options.duration).to.equal(400);
66+
expect(bellows.options.duration).to.be.a('number');
6767
});
6868

6969
it('correctly defines easing as ease-in-out', function() {
7070
var bellows = new Bellows($element, { easing: 'ease-in-out'});
7171

72-
assert.equal(bellows.options.easing, 'ease-in-out');
73-
assert.isString(bellows.options.easing);
72+
expect(bellows.options.easing).to.equal('ease-in-out');
73+
expect(bellows.options.easing).to.be.a('string');
7474
});
7575

7676
it('correctly defines open event', function() {
@@ -79,8 +79,8 @@ define([
7979
};
8080
var bellows = new Bellows($element, { open: open });
8181

82-
assert.equal(bellows.options.open, open);
83-
assert.isFunction(bellows.options.open);
82+
expect(bellows.options.open).to.equal(open);
83+
expect(bellows.options.open).to.be.a('function');
8484
});
8585

8686
it('correctly defines open event', function() {
@@ -89,8 +89,8 @@ define([
8989
};
9090
var bellows = new Bellows($element, { open: open });
9191

92-
assert.equal(bellows.options.open, open);
93-
assert.isFunction(bellows.options.open);
92+
expect(bellows.options.open).to.equal(open);
93+
expect(bellows.options.open).to.be.a('function');
9494
});
9595

9696
it('correctly defines opened event', function() {
@@ -99,8 +99,8 @@ define([
9999
};
100100
var bellows = new Bellows($element, { opened: opened });
101101

102-
assert.equal(bellows.options.opened, opened);
103-
assert.isFunction(bellows.options.opened);
102+
expect(bellows.options.opened).to.equal(opened);
103+
expect(bellows.options.opened).to.be.a('function');
104104
});
105105

106106
it('correctly defines close event', function() {
@@ -109,8 +109,8 @@ define([
109109
};
110110
var bellows = new Bellows($element, { close: close });
111111

112-
assert.equal(bellows.options.close, close);
113-
assert.isFunction(bellows.options.close);
112+
expect(bellows.options.close).to.equal(close);
113+
expect(bellows.options.close).to.be.a('function');
114114
});
115115

116116
it('correctly defines closed event', function() {
@@ -119,8 +119,8 @@ define([
119119
};
120120
var bellows = new Bellows($element, { closed: closed });
121121

122-
assert.equal(bellows.options.closed, closed);
123-
assert.isFunction(bellows.options.closed);
122+
expect(bellows.options.closed).to.equal(closed);
123+
expect(bellows.options.closed).to.be.a('function');
124124
});
125125
});
126126
});

tests/unit/plugin.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,47 @@ define([
2626
it('defines bellows in Zepto', function() {
2727
var bellows = $.fn.bellows;
2828

29-
assert.isDefined(bellows);
29+
expect(bellows).to.be.defined;
3030
});
3131

3232
it('defines bellows as a function', function() {
3333
var bellows = $.fn.bellows;
3434

35-
assert.isFunction(bellows);
35+
expect(bellows).to.be.a('function');
3636
});
3737
});
3838

3939
describe('invoking bellows', function() {
4040
it('creates bellows instance on $element', function() {
4141
$element.bellows();
4242

43-
assert.isDefined($element.data('bellows'));
43+
expect($element.data('bellows')).to.be.defined;
4444
});
4545

4646
it('stores $element inside instance', function() {
4747
$element.bellows();
4848

49-
assert.isDefined($element.data('bellows').$bellows);
49+
expect($element.data('bellows').$bellows).to.be.defined;
5050
});
5151

5252
it('wraps each content section with correct CSS class', function() {
5353
$element.bellows();
5454

55-
assert.lengthOf($element.find('.bellows__content-wrapper'), 2);
55+
expect($element.find('.bellows__content-wrapper')).to.have.length(2);
5656
});
5757
});
5858

5959
describe('invoking bellows methods before plugin is initialized', function() {
6060
it('throws when not initialized', function() {
61-
assert.throws(function() { $element.bellows('open'); });
61+
expect(function() { $element.bellows('open'); }).to.throw;
6262
});
6363
});
6464

6565
describe('invoking bellows methods using the plugin interface', function() {
6666
it('opens a bellows item using the open method', function(done) {
6767
$element.bellows({
6868
opened: function(e, ui) {
69-
assert.isTrue(ui.item.hasClass('bellows--is-open'));
69+
expect(ui.item.hasClass('bellows--is-open')).to.be.true;
7070
done();
7171
}
7272
});
@@ -80,7 +80,7 @@ define([
8080
$element.bellows('close', 0);
8181
},
8282
closed: function(e, ui) {
83-
assert.isFalse(ui.item.hasClass('bellows--is-open'));
83+
expect(ui.item.hasClass('bellows--is-open')).to.be.false;
8484
done();
8585
}
8686
});
@@ -91,7 +91,7 @@ define([
9191
it('removes aria-hidden attribute when open', function(done) {
9292
$element.bellows({
9393
opened: function(e, ui) {
94-
assert.isFalse(!!ui.item.find('.bellows__content-wrapper').attr('aria-hidden'));
94+
expect(!!ui.item.find('.bellows__content-wrapper').attr('aria-hidden')).to.be.false;
9595
done();
9696
}
9797
});
@@ -105,7 +105,7 @@ define([
105105
$element.bellows('close', 0);
106106
},
107107
closed: function(e, ui) {
108-
assert.isTrue(!!ui.item.find('.bellows__content-wrapper').attr('aria-hidden'));
108+
expect(!!ui.item.find('.bellows__content-wrapper').attr('aria-hidden')).to.be.true;
109109
done();
110110
}
111111
});
@@ -131,19 +131,19 @@ define([
131131

132132
$element.bellows('add', item, true);
133133

134-
assert.equal($element.find('.bellows__item').length, 1);
134+
expect($element.find('.bellows__item')).to.have.length(1);
135135
});
136136

137137
it('throws for method calls that don\'t exist', function() {
138-
assert.throws(function() { $element.bellows().bellows('noMethod'); });
138+
expect(function() { $element.bellows().bellows('noMethod'); }).to.throw;
139139
});
140140

141141
it('throws when attempting to invoke private methods', function() {
142-
assert.throws(function() { $element.bellows().bellows('_init'); });
142+
expect(function() { $element.bellows().bellows('_init'); }).to.throw;
143143
});
144144

145145
it('throws when attempting to invoke methods that aren\'t functions', function() {
146-
assert.throws(function() { $element.bellows().bellows('singleItemOpen'); });
146+
expect(function() { $element.bellows().bellows('singleItemOpen'); }).to.throw;
147147
});
148148
});
149149

@@ -160,8 +160,8 @@ define([
160160
.trigger('click');
161161

162162
setTimeout(function() {
163-
assert.isTrue($disabledItem.hasClass('bellows--is-disabled'));
164-
assert.isFalse($disabledItem.hasClass('bellows--is-open'));
163+
expect($disabledItem.hasClass('bellows--is-disabled')).to.be.true;
164+
expect($disabledItem.hasClass('bellows--is-open')).to.be.false;
165165
done();
166166
});
167167
});

0 commit comments

Comments
 (0)