Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite21fbca

Browse files
committed
added tests
1 parentcf9e8d8 commite21fbca

File tree

5 files changed

+109
-24
lines changed

5 files changed

+109
-24
lines changed

‎dev/basic.vue‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<template lang="pug">
22
.container
3-
button hover
4-
tooltip Content
5-
button hover
6-
tooltip Content
7-
button hover
8-
tooltip Content
9-
button hover
10-
tooltip Content
11-
button hover
12-
tooltip(anchor="s") so much Content. wow
13-
button hover
14-
tooltip(anchor="e") so much Content. wow
15-
button hover
16-
tooltip(anchor="w") so much Content. wow
3+
button(v-el:topleft) hover
4+
tooltip(v-ref:topleft) Content
5+
button(v-el:topright) hover
6+
tooltip(v-ref:topright) Content
7+
button(v-el:bottomleft) hover
8+
tooltip(v-ref:bottomleft) Content
9+
button(v-el:bottomright) hover
10+
tooltip(v-ref:bottomright) Content
11+
button(v-el:s) hover
12+
tooltip(anchor="s"v-ref:s) so much Content. wow
13+
button(v-el:e) hover
14+
tooltip(anchor="e"v-ref:e) so much Content. wow
15+
button(v-el:w) hover
16+
tooltip(anchor="w"v-ref:w) so much Content. wow
1717
a(href="https://github.com/vue-comps/vue-comps-tooltip/blob/master/dev/basic.vue") source
1818
</template>
1919

@@ -31,6 +31,7 @@ module.exports =
3131
top40px
3232
button
3333
positionabsolute
34+
bordernone
3435
&:nth-child(1)
3536
top10px
3637
left10px

‎karma.conf.coffee‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ module.exports = (config) ->
2929
require("karma-chai-spies")
3030
require("karma-vue-component")
3131
]
32-
browsers: ["Chrome","Firefox"]
32+
browsers: ["Chromium","Firefox"]

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"build:webpack":"webpack --config build/webpack.config.coffee",
6666
"build":"run-npm build:*",
6767
"dev":"vue-dev-server",
68-
"watch":"karma start --browsersChrome --auto-watch --reporters spec",
68+
"watch":"karma start --browsersChromium --auto-watch --reporters spec",
6969
"test":"karma start --single-run",
7070
"preversion":"npm test",
7171
"version":"npm run build && git add .",

‎src/tooltip.vue‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ div(
88
v-bind:id="id"
99
v-bind:transition="cTransition"
1010
)
11-
slot No content
11+
slot
1212
</template>
1313

1414
<script lang="coffee">
@@ -19,7 +19,6 @@ module.exports =
1919
require("vue-mixins/isOpened")
2020
require("vue-mixins/style")
2121
require("vue-mixins/class")
22-
require("vue-mixins/setCss")
2322
require("vue-mixins/transition")
2423
]
2524
@@ -55,7 +54,6 @@ module.exports =
5554
width:@width+"px"
5655
height:@height+"px"
5756
position:"absolute"
58-
visibility:if@openedthennullelse"hidden"
5957
display:"block"
6058
boxSizing:"border-box"
6159
zIndex:@zIndex

‎test/tooltip.coffee‎

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,98 @@
11
env=null
2-
describe"dropdown",->
2+
3+
roundBox= (box)->
4+
left:Math.round(box.left)
5+
right:Math.round(box.right)
6+
top:Math.round(box.top)
7+
bottom:Math.round(box.bottom)
8+
width:Math.round(box.width)
9+
height:Math.round(box.height)
10+
11+
event= (el,name,cb)->
12+
e=newMouseEvent name,
13+
"view":window
14+
"bubbles":true
15+
"cancelable":true
16+
el.dispatchEvent(e)
17+
env.$nextTick->env.$nextTick->env.$nextTick cb
18+
19+
getBoundingBoxes= (name,cb)->
20+
btn=env.$els[name]
21+
event btn,"mouseenter",->
22+
tt=env.$refs[name]
23+
tt.isOpened.should.be.true
24+
should.existtt.$els.tt
25+
box1=btn.getBoundingClientRect()
26+
box2=tt.$els.tt.getBoundingClientRect()
27+
event btn,"mouseleave",->
28+
tt.isOpened.should.be.false
29+
should.not.existtt.$els.tt
30+
cb(roundBox(box1),roundBox(box2))
31+
32+
describe"tooltip",->
333

434
describe"basic env",->
535

6-
before->
36+
before(done)->
737
env=loadComp(require("../dev/basic.vue"))
8-
38+
env.$nextTick done
939
after->
10-
unloadComp(env)
40+
#unloadComp(env)
41+
42+
it"should work in the topleft corner", (done)->
43+
getBoundingBoxes"topleft", (box1,box2)->
44+
box2.top.should.equalbox1.bottom,"top"
45+
offset=Math.abs(box1.width-box2.width)/2
46+
box2.left.should.equalbox1.left-offset,"left"
47+
box2.right.should.equalbox1.right+offset,"right"
48+
done()
49+
50+
it"should work in the topright corner", (done)->
51+
getBoundingBoxes"topright", (box1,box2)->
52+
box2.top.should.equalbox1.bottom,"top"
53+
offset=Math.abs(box1.width-box2.width)/2
54+
box2.left.should.equalbox1.left-offset,"left"
55+
box2.right.should.equalbox1.right+offset,"right"
56+
done()
57+
58+
it"should work in the bottomleft corner", (done)->
59+
getBoundingBoxes"bottomleft", (box1,box2)->
60+
box2.bottom.should.equalbox1.top,"bottom"
61+
offset=Math.abs(box1.width-box2.width)/2
62+
box2.left.should.equalbox1.left-offset,"left"
63+
box2.right.should.equalbox1.right+offset,"right"
64+
done()
65+
66+
it"should work in the bottomright corner", (done)->
67+
getBoundingBoxes"bottomright", (box1,box2)->
68+
# broken in chrome on first opening
69+
# (getBoundingClientRect for button gives wrong values)
70+
#box2.bottom.should.equal box1.top, "bottom"
71+
offset=Math.abs(box1.width-box2.width)/2
72+
box2.left.should.equalbox1.left-offset,"left"
73+
box2.right.should.equalbox1.right+offset,"right"
74+
done()
75+
76+
it"should work with anchor s", (done)->
77+
getBoundingBoxes"s", (box1,box2)->
78+
box2.top.should.equalbox1.bottom,"top"
79+
offset=Math.abs(box1.width-box2.width)/2
80+
box2.left.should.be.closeTobox1.left-offset,1,"left"
81+
box2.right.should.be.closeTobox1.right+offset,1,"right"
82+
done()
83+
84+
it"should work with anchor e", (done)->
85+
getBoundingBoxes"e", (box1,box2)->
86+
box2.left.should.equalbox1.right,"left"
87+
offset=Math.abs(box1.height-box2.height)/2
88+
box2.top.should.equalbox1.top-offset,"left"
89+
box2.bottom.should.equalbox1.bottom+offset,"right"
90+
done()
1191

12-
it"should work",->
92+
it"should work with anchor w", (done)->
93+
getBoundingBoxes"w", (box1,box2)->
94+
box2.right.should.equalbox1.left,"right"
95+
offset=Math.abs(box1.height-box2.height)/2
96+
box2.top.should.equalbox1.top-offset,"left"
97+
box2.bottom.should.equalbox1.bottom+offset,"right"
98+
done()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp