Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
cf1e8f29
Commit
cf1e8f29
authored
Jul 15, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing test for emoji picker
parent
4ea50de9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
40 deletions
+60
-40
spec/chatbox.js
spec/chatbox.js
+31
-25
src/converse-chatview.js
src/converse-chatview.js
+5
-1
src/templates/emojis.html
src/templates/emojis.html
+1
-1
src/utils.js
src/utils.js
+19
-10
tests/mock.js
tests/mock.js
+4
-3
No files found.
spec/chatbox.js
View file @
cf1e8f29
...
...
@@ -385,36 +385,42 @@
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
rosterview
.
$el
.
find
(
'
dt
'
).
length
;
},
300
)
.
then
(
function
()
{
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
view
,
$toolbar
,
$textarea
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
$toolbar
=
view
.
$el
.
find
(
'
ul.chat-toolbar
'
);
$textarea
=
view
.
$el
.
find
(
'
textarea.chat-textarea
'
);
expect
(
$toolbar
.
children
(
'
li.toggle-smiley
'
).
length
).
toBe
(
1
);
// Register spies
spyOn
(
view
,
'
toggleEmojiMenu
'
).
and
.
callThrough
();
spyOn
(
view
,
'
insertEmoji
'
);
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
view
,
$toolbar
,
$textarea
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
$toolbar
=
view
.
$el
.
find
(
'
ul.chat-toolbar
'
);
$textarea
=
view
.
$el
.
find
(
'
textarea.chat-textarea
'
);
expect
(
$toolbar
.
children
(
'
li.toggle-smiley
'
).
length
).
toBe
(
1
);
// Register spies
spyOn
(
view
,
'
toggleEmojiMenu
'
).
and
.
callThrough
();
spyOn
(
view
,
'
insertEmoji
'
).
and
.
callThrough
();
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
test_utils
.
waitUntil
(
function
()
{
var
$picker
=
view
.
$el
.
find
(
'
.toggle-smiley .emoji-picker-container
'
);
return
$picker
.
is
(
'
:visible
'
);
},
300
).
then
(
function
()
{
var
$picker
=
view
.
$el
.
find
(
'
.toggle-smiley .emoji-picker-container
'
);
// expect($picker.is(':visible')).toBeTruthy();
// expect(view.toggleEmojiMenu).toHaveBeenCalled();
var
$items
=
$picker
.
find
(
'
.emoji-picker li
'
);
$items
.
first
().
click
();
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
expect
(
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
expect
(
view
.
toggleEmojiMenu
).
toHaveBeenCalled
();
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
children
(
'
li
'
).
last
().
click
();
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
expect
(
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
done
();
test_utils
.
waitUntil
(
function
()
{
return
!
view
.
el
.
querySelector
(
'
.toggle-smiley .toolbar-menu
'
).
offsetHeight
;
},
300
).
then
(
function
()
{
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
expect
(
view
.
toggleEmojiMenu
).
toHaveBeenCalled
();
test_utils
.
waitUntil
(
function
()
{
var
$picker
=
view
.
$el
.
find
(
'
.toggle-smiley .emoji-picker-container
'
);
return
$picker
.
is
(
'
:visible
'
);
},
300
).
then
(
function
()
{
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
children
(
'
li
'
).
last
().
click
();
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
done
();
});
});
});
}));
...
...
src/converse-chatview.js
View file @
cf1e8f29
...
...
@@ -55,7 +55,11 @@
registerGlobalEventHandlers
:
function
()
{
this
.
__super__
.
registerGlobalEventHandlers
();
document
.
addEventListener
(
'
click
'
,
function
()
{
'
click
'
,
function
(
ev
)
{
if
(
_
.
includes
(
ev
.
target
.
classList
,
'
toggle-toolbar-menu
'
)
||
_
.
includes
(
ev
.
target
.
classList
,
'
insert-emoji
'
))
{
return
;
}
utils
.
slideInAllElements
(
document
.
querySelectorAll
(
'
.toolbar-menu
'
)
)
...
...
src/templates/emojis.html
View file @
cf1e8f29
{[ _.forEach(emojis_by_category, function (obj, category) { ]}
<ul
class=
"emoji-picker emoji-picker-{{{category}}} {[ if (current_category !== category) { ]} hidden {[ } ]}"
>
{[ _.forEach(emojis_by_category[category], function (emoji) { ]}
<li
class=
"emoji"
data-emoji=
"{{{emoji._shortname}}}"
>
<li
class=
"emoji
insert-emoji
"
data-emoji=
"{{{emoji._shortname}}}"
>
<a
href=
"#"
data-emoji=
"{{{emoji._shortname}}}"
>
{{ emojione.shortnameToUnicode(emoji._shortname) }}
</a>
</li>
{[ }); ]}
...
...
src/utils.js
View file @
cf1e8f29
...
...
@@ -208,17 +208,25 @@
const
err
=
"
Undefined or null element passed into slideOut
"
console
.
warn
(
err
);
reject
(
new
Error
(
err
));
return
;
}
let
interval_marker
=
el
.
getAttribute
(
'
data-slider-marker
'
);
if
(
interval_marker
)
{
el
.
removeAttribute
(
'
data-slider-marker
'
);
window
.
clearInterval
(
interval_marker
);
}
const
end_height
=
_
.
reduce
(
el
.
children
,
function
(
result
,
child
)
{
return
result
+
child
.
offsetHeight
;
},
0
);
const
end_height
=
_
.
reduce
(
el
.
children
,
(
result
,
child
)
=>
result
+
child
.
offsetHeight
,
0
);
if
(
$
.
fx
.
off
)
{
// Effects are disabled (for tests)
el
.
style
.
height
=
end_height
+
'
px
'
;
resolve
();
return
;
}
const
step
=
calculateSlideStep
(
end_height
),
interval
=
end_height
/
duration
*
step
;
let
h
=
0
;
interval_marker
=
window
.
setInterval
(
function
()
{
h
+=
step
;
...
...
@@ -227,7 +235,6 @@
}
else
{
el
.
style
.
height
=
end_height
+
'
px
'
;
window
.
clearInterval
(
interval_marker
);
el
.
style
.
overflow
=
''
;
el
.
removeAttribute
(
'
data-slider-marker
'
);
resolve
();
}
...
...
@@ -242,14 +249,16 @@
if
(
_
.
isNil
(
el
))
{
const
err
=
"
Undefined or null element passed into slideIn
"
;
console
.
warn
(
err
);
reject
(
new
Error
(
err
));
}
if
(
!
el
.
offsetHeight
)
{
resolve
();
return
;
return
reject
(
new
Error
(
err
));
}
else
if
(
!
el
.
offsetHeight
)
{
return
resolve
();
}
else
if
(
$
.
fx
.
off
)
{
// Effects are disabled (for tests)
el
.
style
.
height
=
0
+
'
px
'
;
return
resolve
();
}
let
interval_marker
=
el
.
getAttribute
(
'
data-slider-marker
'
);
if
(
interval_marker
)
{
el
.
removeAttribute
(
'
data-slider-marker
'
);
window
.
clearInterval
(
interval_marker
);
}
let
h
=
el
.
offsetHeight
;
...
...
tests/mock.js
View file @
cf1e8f29
...
...
@@ -88,7 +88,7 @@
});
}
var
converse
=
converse_api
.
initialize
(
_
.
extend
({
var
_
converse
=
converse_api
.
initialize
(
_
.
extend
({
'
i18n
'
:
'
en
'
,
'
auto_subscribe
'
:
false
,
'
play_sounds
'
:
false
,
...
...
@@ -101,9 +101,10 @@
'
password
'
:
'
secret
'
,
'
debug
'
:
false
},
settings
||
{}));
converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
disable_effects
=
true
;
$
.
fx
.
off
=
true
;
return
converse
;
return
_
converse
;
}
mock
.
initConverseWithPromises
=
function
(
spies
,
promise_names
,
settings
,
func
)
{
...
...
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