Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
b85b67d9
Commit
b85b67d9
authored
Oct 26, 2017
by
wacky6.AriesMBP
Committed by
杨奕
Oct 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: add change event test for input-number
parent
c856d926
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
21 deletions
+44
-21
test/unit/specs/input-number.spec.js
test/unit/specs/input-number.spec.js
+44
-21
No files found.
test/unit/specs/input-number.spec.js
View file @
b85b67d9
import
{
createVue
,
triggerEvent
,
triggerClick
,
destroyVM
}
from
'
../util
'
;
const
DELAY
=
1
;
describe
(
'
InputNumber
'
,
()
=>
{
let
vm
;
afterEach
(()
=>
{
...
...
@@ -263,30 +265,51 @@ describe('InputNumber', () => {
});
});
});
it
(
'
event:change
'
,
done
=>
{
vm
=
createVue
({
template
:
`
<el-input-number v-model="value" ref="input">
</el-input-number>
`
,
data
()
{
return
{
value
:
1.5
};
}
},
true
);
let
btnIncrease
=
vm
.
$el
.
querySelector
(
'
.el-input-number__increase
'
);
const
spy
=
sinon
.
spy
();
describe
(
'
event:change
'
,
()
=>
{
let
spy
;
beforeEach
(()
=>
{
vm
=
createVue
({
template
:
`
<el-input-number v-model="value" ref="compo" :min='2' :max='3' :step='1'>
</el-input-number>
`
,
data
()
{
return
{
value
:
2
};
}
},
true
);
spy
=
sinon
.
spy
();
vm
.
$refs
.
compo
.
$on
(
'
change
'
,
spy
);
});
vm
.
$refs
.
input
.
$on
(
'
change
'
,
spy
);
it
(
'
emit on input
'
,
done
=>
{
vm
.
$refs
.
compo
.
handleInput
(
'
3
'
);
setTimeout
(
_
=>
{
expect
(
spy
.
calledOnce
).
to
.
be
.
true
;
expect
(
spy
.
args
[
0
][
0
]).
to
.
equal
(
3
);
done
();
},
DELAY
);
});
triggerEvent
(
btnIncrease
,
'
mousedown
'
);
triggerClick
(
document
,
'
mouseup
'
);
it
(
'
emit on button
'
,
done
=>
{
const
btnIncrease
=
vm
.
$el
.
querySelector
(
'
.el-input-number__increase
'
);
triggerEvent
(
btnIncrease
,
'
mousedown
'
);
triggerClick
(
document
,
'
mouseup
'
);
setTimeout
(
_
=>
{
expect
(
spy
.
calledOnce
).
to
.
be
.
true
;
expect
(
spy
.
args
[
0
][
0
]).
to
.
equal
(
3
);
done
();
},
DELAY
);
});
vm
.
$nextTick
(
_
=>
{
expect
(
spy
.
withArgs
(
2.5
,
1.5
).
calledOnce
).
to
.
be
.
true
;
done
();
it
(
'
does not emit on programatic change
'
,
done
=>
{
vm
.
value
=
3
;
setTimeout
(
_
=>
{
expect
(
spy
.
notCalled
).
to
.
be
.
true
;
done
();
},
DELAY
);
});
});
it
(
'
event:focus & blur
'
,
done
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment