File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
test/unit/specs/mount/Wrapper Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,8 @@ export default class Wrapper implements BaseWrapper {
77
77
throwError ( 'wrapper.hasClass() must be passed a string' )
78
78
}
79
79
80
- return this . element . className . split ( ' ' ) . indexOf ( className ) !== - 1
80
+ return ! ! ( this . element &&
81
+ this . element . className . split ( ' ' ) . indexOf ( className ) !== - 1 )
81
82
}
82
83
83
84
/**
Original file line number Diff line number Diff line change @@ -14,6 +14,19 @@ describe('hasClass', () => {
14
14
expect ( wrapper . hasClass ( 'not-class-name' ) ) . to . equal ( false )
15
15
} )
16
16
17
+ it ( 'returns false if wrapper includes class name in string, but not as a seperate class' , ( ) => {
18
+ const compiled = compileToFunctions ( '<div class="class-name-together"/>' )
19
+ const wrapper = mount ( compiled )
20
+ expect ( wrapper . hasClass ( 'class-name' ) ) . to . equal ( false )
21
+ } )
22
+
23
+ it ( 'returns false if wrapper does not have an element' , ( ) => {
24
+ const compiled = compileToFunctions ( '<div />' )
25
+ const wrapper = mount ( compiled )
26
+ wrapper . element = null
27
+ expect ( wrapper . hasClass ( 'not-class-name' ) ) . to . equal ( false )
28
+ } )
29
+
17
30
it ( 'throws an error if selector is not a string' , ( ) => {
18
31
const compiled = compileToFunctions ( '<div />' )
19
32
const wrapper = mount ( compiled )
You can’t perform that action at this time.
0 commit comments