Skip to content

Commit 3959b67

Browse files
committed
use better warning assertions in tests
1 parent dffd4c7 commit 3959b67

File tree

17 files changed

+33
-30
lines changed

17 files changed

+33
-30
lines changed

src/directives/model/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = {
4545
} else if (tag === 'TEXTAREA') {
4646
handler = handlers._default
4747
} else {
48-
_.warn("v-model doesn't support element type: " + tag)
48+
_.warn('v-model does not support element type: ' + tag)
4949
return
5050
}
5151
handler.bind.call(this)

test/unit/runner.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Vue.js unit tests</title>
6-
<link rel="shortcut icon" type="image/png" href="lib/jasmine_favicon.png">
76
<link rel="stylesheet" type="text/css" href="lib/jasmine.css">
87
<script src="lib/jquery.js"></script>
98
<script src="lib/jasmine.js"></script>

test/unit/specs/api/data_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Data API', function () {
2929
expect(vm.$get('c')).toBeUndefined()
3030
// invalid, should warn
3131
vm.$get('a(')
32-
expect(_.warn).toHaveBeenCalled()
32+
expect(hasWarned(_, 'Invalid expression')).toBe(true)
3333
})
3434

3535
it('$set', function () {
@@ -46,7 +46,7 @@ describe('Data API', function () {
4646
// expression throws, the exp parser will catch the
4747
// error and warn.
4848
vm.$set('c + d', 1)
49-
expect(_.warn).toHaveBeenCalled()
49+
expect(hasWarned(_, 'Invalid setter function body')).toBe(true)
5050
} else {
5151
// otherwise it will throw when calling the setter.
5252
expect(function () {

test/unit/specs/api/lifecycle_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if (_.inBrowser) {
5757
it('warn invalid selector', function () {
5858
var vm = new Vue()
5959
vm.$mount('#none-exist')
60-
expect(_.warn).toHaveBeenCalled()
60+
expect(hasWarned(_, 'Cannot find element')).toBe(true)
6161
})
6262

6363
it('replace', function () {
@@ -145,7 +145,7 @@ if (_.inBrowser) {
145145
el: el
146146
})
147147
vm.$mount(el)
148-
expect(_.warn).toHaveBeenCalled()
148+
expect(hasWarned(_, '$mount() should be called only once')).toBe(true)
149149
})
150150

151151
})

test/unit/specs/batcher_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('Batcher', function () {
9494
batcher.push(job)
9595
nextTick(function () {
9696
expect(count).not.toBe(0)
97-
expect(_.warn).toHaveBeenCalled()
97+
expect(hasWarned(_, 'infinite update loop')).toBe(true)
9898
done()
9999
})
100100
})

test/unit/specs/compiler/transclude_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (_.inBrowser) {
2727
options.template = '#non-existent-stuff'
2828
var res = transclude(el, options)
2929
expect(res).toBeUndefined()
30-
expect(_.warn).toHaveBeenCalled()
30+
expect(hasWarned(_, 'Invalid template option')).toBe(true)
3131
})
3232

3333
it('template replace', function () {

test/unit/specs/directives/component_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ if (_.inBrowser) {
379379
var vm = new Vue({
380380
el: el
381381
})
382-
expect(_.warn).toHaveBeenCalled()
382+
expect(hasWarned(_, 'already mounted instance')).toBe(true)
383383
})
384384

385385
})

test/unit/specs/directives/events_spec.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ if (_.inBrowser) {
3434
el: el,
3535
template: '<div v-events="test:test"></div>'
3636
})
37-
expect(_.warn).toHaveBeenCalled()
37+
expect(hasWarned(_,
38+
'should only be used on a child component ' +
39+
'from the parent template')).toBe(true)
3840
})
3941

4042
it('should warn when used on child component root', function () {
@@ -55,7 +57,9 @@ if (_.inBrowser) {
5557
}
5658
}
5759
})
58-
expect(_.warn).toHaveBeenCalled()
60+
expect(hasWarned(_,
61+
'should only be used on a child component ' +
62+
'from the parent template')).toBe(true)
5963
expect(spy).not.toHaveBeenCalled()
6064
})
6165

@@ -68,7 +72,7 @@ if (_.inBrowser) {
6872
test: {}
6973
}
7074
})
71-
expect(_.warn).toHaveBeenCalled()
75+
expect(hasWarned(_, 'expects a function value')).toBe(true)
7276
})
7377

7478
it('should accept inline statement', function (done) {

test/unit/specs/directives/if_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ if (_.inBrowser) {
177177
var vm = new Vue({
178178
el: el
179179
})
180-
expect(_.warn).toHaveBeenCalled()
180+
expect(hasWarned(_, 'already mounted instance')).toBe(true)
181181
})
182182

183183
it('v-if with content transclusion', function (done) {

test/unit/specs/directives/model_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ if (_.inBrowser) {
557557
el: el,
558558
template: '<div v-model="test"></div>'
559559
})
560-
expect(_.warn).toHaveBeenCalled()
560+
expect(hasWarned(_, 'does not support element type')).toBe(true)
561561
})
562562

563563
it('warn invalid option value', function () {
@@ -566,7 +566,7 @@ if (_.inBrowser) {
566566
data: { a: 123 },
567567
template: '<select v-model="test" options="a"></select>'
568568
})
569-
expect(_.warn).toHaveBeenCalled()
569+
expect(hasWarned(_, 'Invalid options value')).toBe(true)
570570
})
571571

572572
it('warn read-only filters', function () {
@@ -579,7 +579,7 @@ if (_.inBrowser) {
579579
}
580580
}
581581
})
582-
expect(_.warn).toHaveBeenCalled()
582+
expect(hasWarned(_, 'read-only filter')).toBe(true)
583583
})
584584

585585
it('support jQuery change event', function (done) {

0 commit comments

Comments
 (0)