Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.

Commit 8c24f1b

Browse files
committed
Tweak tests
1 parent 75d2fc3 commit 8c24f1b

File tree

1 file changed

+43
-53
lines changed

1 file changed

+43
-53
lines changed
Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,48 @@
11
import { test, moduleForComponent } from 'ember-qunit';
2+
import startApp from '../../helpers/start-app';
23
import Ember from 'ember';
34

4-
moduleForComponent('bootstrap-datepicker', 'bootstrap-datepicker component', {});
5+
var App;
56

6-
test('should be an input tag', function(assert) {
7-
assert.expect(1);
8-
9-
assert.equal('INPUT', this.$().prop('tagName'));
7+
moduleForComponent('bootstrap-datepicker', 'BootstrapDatepickerComponent', {
8+
beforeEach: function() {
9+
App = startApp();
10+
},
11+
afterEach: function() {
12+
Ember.run(App, 'destroy');
13+
}
1014
});
1115

12-
test('should display empty input field when no date is set', function(assert) {
13-
assert.expect(1);
16+
test('is an input tag', function(assert) {
17+
assert.equal(this.$().prop('tagName'), 'INPUT');
18+
});
1419

15-
var component = this.subject({
20+
test('displays empty input field when no date is set', function(assert) {
21+
this.subject({
1622
value: null
1723
});
1824

1925
assert.equal(this.$().val(), '');
2026
});
2127

22-
23-
test('should display date with default format when no format is set', function(assert) {
24-
assert.expect(1);
25-
26-
var component = this.subject({
28+
test('displays date with default format when no format is set', function(assert) {
29+
this.subject({
2730
value: new Date(2014, 11, 31)
2831
});
2932

3033
assert.equal(this.$().val(), '12/31/2014');
3134
});
3235

33-
test('should reset date when input is cleared', function(assert) {
34-
assert.expect(2);
36+
test('displays date with custom format when format is set', function(assert) {
37+
this.subject({
38+
value: new Date(2014, 11, 31),
39+
format: 'dd.M.yy'
40+
});
3541

42+
assert.equal(this.$().val(), '31.Dec.14');
43+
});
44+
45+
test('resets date when input is cleared', function(assert) {
3646
this.subject({
3747
value: new Date(2014, 11, 31)
3848
});
@@ -45,44 +55,28 @@ test('should reset date when input is cleared', function(assert) {
4555
assert.equal(this.$().datepicker('getDate'), null, 'value is reset when input is cleared');
4656
});
4757

48-
test('should display date with custom format when format is set', function(assert) {
49-
assert.expect(1);
50-
51-
var component = this.subject({
52-
value: new Date(2014, 11, 31),
53-
format: 'dd.M.yy'
54-
});
55-
56-
assert.equal(this.$().val(), '31.Dec.14');
57-
});
58-
59-
test('should set dates provided by value (multidate, default multidateSeparator)', function(assert) {
60-
assert.expect(2);
61-
62-
var component = this.subject({
58+
test('sets dates provided by value (multidate, default multidateSeparator)', function(assert) {
59+
this.subject({
6360
value: [new Date(2015, 0, 13), new Date(2015, 0, 7), new Date(2015, 0, 15)],
6461
multidate: true
6562
});
6663

67-
assert.equal(this.$().val(), '01/13/2015,01/07/2015,01/15/2015', 'should set value as input field value');
68-
assert.equal(this.$().datepicker('getDates').length, 3, 'should set internal datepicker dates by value');
64+
assert.equal(this.$().val(), '01/13/2015,01/07/2015,01/15/2015', 'sets value as input field value');
65+
assert.equal(this.$().datepicker('getDates').length, 3, 'sets internal datepicker dates by value');
6966
});
7067

71-
test('should set dates provided by value (multidate, multidateSeparator provided)', function(assert) {
72-
assert.expect(2);
73-
74-
var component = this.subject({
68+
test('sets dates provided by value (multidate, multidateSeparator provided)', function(assert) {
69+
this.subject({
7570
value: [new Date(2015, 0, 13), new Date(2015, 0, 7), new Date(2015, 0, 15)],
7671
multidate: true,
7772
multidateSeparator: ';'
7873
});
7974

80-
assert.equal(this.$().val(), '01/13/2015;01/07/2015;01/15/2015', 'should set value as input field value using multidate separator');
81-
assert.equal(this.$().datepicker('getDates').length, 3, 'should set internal datepicker dates by value');
75+
assert.equal(this.$().val(), '01/13/2015;01/07/2015;01/15/2015', 'sets value as input field value using multidate separator');
76+
assert.equal(this.$().datepicker('getDates').length, 3, 'sets internal datepicker dates by value');
8277
});
8378

84-
test('should update startDate', function(assert) {
85-
assert.expect(2);
79+
test('updates startDate', function(assert) {
8680
var startDate = new Date(2015, 2);
8781
var newStartDate = new Date(2015, 3);
8882

@@ -91,15 +85,13 @@ test('should update startDate', function(assert) {
9185
startDate: startDate
9286
});
9387

94-
assert.equal(this.$().datepicker("setDate").o.startDate.getMonth(), startDate.getMonth(), 'should set initial startDate');
88+
assert.equal(this.$().data('datepicker').o.startDate.getMonth(), startDate.getMonth(), 'sets initial startDate');
9589

96-
component.set("startDate", newStartDate);
97-
assert.equal(this.$().datepicker("setDate").o.startDate.getMonth(), newStartDate.getMonth(), 'should update startDate');
90+
component.set('startDate', newStartDate);
91+
assert.equal(this.$().data('datepicker').o.startDate.getMonth(), newStartDate.getMonth(), 'updates startDate');
9892
});
9993

100-
test('should update format', function(assert) {
101-
assert.expect(2);
102-
94+
test('updates format', function(assert) {
10395
var format = 'mm/yyyy';
10496
var newFormat = 'yyyy';
10597

@@ -108,16 +100,14 @@ test('should update format', function(assert) {
108100
format: format
109101
});
110102

111-
assert.equal(this.$().data('datepicker').o.format, format, 'should set initial format');
103+
assert.equal(this.$().data('datepicker').o.format, format, 'sets initial format');
112104

113105
component.set('format', newFormat);
114106

115-
assert.equal(this.$().data('datepicker').o.format, newFormat, 'should update format');
107+
assert.equal(this.$().data('datepicker').o.format, newFormat, 'updates format');
116108
});
117109

118-
test('should update minViewMode', function(assert) {
119-
assert.expect(2);
120-
110+
test('updates minViewMode', function(assert) {
121111
var minViewMode = 'years';
122112
var yearsViewModeNumber = 2;
123113
var newMinViewMode = 'months';
@@ -128,9 +118,9 @@ test('should update minViewMode', function(assert) {
128118
minViewMode: minViewMode
129119
});
130120

131-
assert.equal(this.$().data('datepicker').o.minViewMode, yearsViewModeNumber, 'should set initial format');
121+
assert.equal(this.$().data('datepicker').o.minViewMode, yearsViewModeNumber, 'sets initial minViewMode');
132122

133123
component.set('minViewMode', newMinViewMode);
134124

135-
assert.equal(this.$().data('datepicker').o.minViewMode, monthsViewModeNumber, 'should update format');
125+
assert.equal(this.$().data('datepicker').o.minViewMode, monthsViewModeNumber, 'updates minViewMode');
136126
});

0 commit comments

Comments
 (0)