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
Show 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,10 +385,6 @@
...
@@ -385,10 +385,6 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
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
'
,
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
view
,
$toolbar
,
$textarea
;
view
,
$toolbar
,
$textarea
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -398,24 +394,34 @@
...
@@ -398,24 +394,34 @@
expect
(
$toolbar
.
children
(
'
li.toggle-smiley
'
).
length
).
toBe
(
1
);
expect
(
$toolbar
.
children
(
'
li.toggle-smiley
'
).
length
).
toBe
(
1
);
// Register spies
// Register spies
spyOn
(
view
,
'
toggleEmojiMenu
'
).
and
.
callThrough
();
spyOn
(
view
,
'
toggleEmojiMenu
'
).
and
.
callThrough
();
spyOn
(
view
,
'
insertEmoji
'
);
spyOn
(
view
,
'
insertEmoji
'
).
and
.
callThrough
();
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
$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
'
);
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
'
);
var
$items
=
$picker
.
find
(
'
.emoji-picker li
'
);
$items
.
first
().
click
();
$items
.
first
().
click
();
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
expect
(
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
test_utils
.
waitUntil
(
function
()
{
return
!
view
.
el
.
querySelector
(
'
.toggle-smiley .toolbar-menu
'
).
offsetHeight
;
},
300
).
then
(
function
()
{
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
expect
(
view
.
toggleEmojiMenu
).
toHaveBeenCalled
();
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
();
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
children
(
'
li
'
).
last
().
click
();
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
expect
(
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
done
();
done
();
});
});
});
});
}));
}));
it
(
"
contains a button for starting an encrypted chat session
"
,
it
(
"
contains a button for starting an encrypted chat session
"
,
...
...
src/converse-chatview.js
View file @
cf1e8f29
...
@@ -55,7 +55,11 @@
...
@@ -55,7 +55,11 @@
registerGlobalEventHandlers
:
function
()
{
registerGlobalEventHandlers
:
function
()
{
this
.
__super__
.
registerGlobalEventHandlers
();
this
.
__super__
.
registerGlobalEventHandlers
();
document
.
addEventListener
(
document
.
addEventListener
(
'
click
'
,
function
()
{
'
click
'
,
function
(
ev
)
{
if
(
_
.
includes
(
ev
.
target
.
classList
,
'
toggle-toolbar-menu
'
)
||
_
.
includes
(
ev
.
target
.
classList
,
'
insert-emoji
'
))
{
return
;
}
utils
.
slideInAllElements
(
utils
.
slideInAllElements
(
document
.
querySelectorAll
(
'
.toolbar-menu
'
)
document
.
querySelectorAll
(
'
.toolbar-menu
'
)
)
)
...
...
src/templates/emojis.html
View file @
cf1e8f29
{[ _.forEach(emojis_by_category, function (obj, category) { ]}
{[ _.forEach(emojis_by_category, function (obj, category) { ]}
<ul
class=
"emoji-picker emoji-picker-{{{category}}} {[ if (current_category !== category) { ]} hidden {[ } ]}"
>
<ul
class=
"emoji-picker emoji-picker-{{{category}}} {[ if (current_category !== category) { ]} hidden {[ } ]}"
>
{[ _.forEach(emojis_by_category[category], function (emoji) { ]}
{[ _.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>
<a
href=
"#"
data-emoji=
"{{{emoji._shortname}}}"
>
{{ emojione.shortnameToUnicode(emoji._shortname) }}
</a>
</li>
</li>
{[ }); ]}
{[ }); ]}
...
...
src/utils.js
View file @
cf1e8f29
...
@@ -208,17 +208,25 @@
...
@@ -208,17 +208,25 @@
const
err
=
"
Undefined or null element passed into slideOut
"
const
err
=
"
Undefined or null element passed into slideOut
"
console
.
warn
(
err
);
console
.
warn
(
err
);
reject
(
new
Error
(
err
));
reject
(
new
Error
(
err
));
return
;
}
}
let
interval_marker
=
el
.
getAttribute
(
'
data-slider-marker
'
);
let
interval_marker
=
el
.
getAttribute
(
'
data-slider-marker
'
);
if
(
interval_marker
)
{
if
(
interval_marker
)
{
el
.
removeAttribute
(
'
data-slider-marker
'
);
window
.
clearInterval
(
interval_marker
);
window
.
clearInterval
(
interval_marker
);
}
}
const
end_height
=
_
.
reduce
(
el
.
children
,
function
(
result
,
child
)
{
const
end_height
=
_
.
reduce
(
return
result
+
child
.
offsetHeight
;
el
.
children
,
},
0
);
(
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
),
const
step
=
calculateSlideStep
(
end_height
),
interval
=
end_height
/
duration
*
step
;
interval
=
end_height
/
duration
*
step
;
let
h
=
0
;
let
h
=
0
;
interval_marker
=
window
.
setInterval
(
function
()
{
interval_marker
=
window
.
setInterval
(
function
()
{
h
+=
step
;
h
+=
step
;
...
@@ -227,7 +235,6 @@
...
@@ -227,7 +235,6 @@
}
else
{
}
else
{
el
.
style
.
height
=
end_height
+
'
px
'
;
el
.
style
.
height
=
end_height
+
'
px
'
;
window
.
clearInterval
(
interval_marker
);
window
.
clearInterval
(
interval_marker
);
el
.
style
.
overflow
=
''
;
el
.
removeAttribute
(
'
data-slider-marker
'
);
el
.
removeAttribute
(
'
data-slider-marker
'
);
resolve
();
resolve
();
}
}
...
@@ -242,14 +249,16 @@
...
@@ -242,14 +249,16 @@
if
(
_
.
isNil
(
el
))
{
if
(
_
.
isNil
(
el
))
{
const
err
=
"
Undefined or null element passed into slideIn
"
;
const
err
=
"
Undefined or null element passed into slideIn
"
;
console
.
warn
(
err
);
console
.
warn
(
err
);
reject
(
new
Error
(
err
));
return
reject
(
new
Error
(
err
));
}
}
else
if
(
!
el
.
offsetHeight
)
{
if
(
!
el
.
offsetHeight
)
{
return
resolve
();
resolve
();
}
else
if
(
$
.
fx
.
off
)
{
// Effects are disabled (for tests)
return
;
el
.
style
.
height
=
0
+
'
px
'
;
return
resolve
();
}
}
let
interval_marker
=
el
.
getAttribute
(
'
data-slider-marker
'
);
let
interval_marker
=
el
.
getAttribute
(
'
data-slider-marker
'
);
if
(
interval_marker
)
{
if
(
interval_marker
)
{
el
.
removeAttribute
(
'
data-slider-marker
'
);
window
.
clearInterval
(
interval_marker
);
window
.
clearInterval
(
interval_marker
);
}
}
let
h
=
el
.
offsetHeight
;
let
h
=
el
.
offsetHeight
;
...
...
tests/mock.js
View file @
cf1e8f29
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
});
});
}
}
var
converse
=
converse_api
.
initialize
(
_
.
extend
({
var
_
converse
=
converse_api
.
initialize
(
_
.
extend
({
'
i18n
'
:
'
en
'
,
'
i18n
'
:
'
en
'
,
'
auto_subscribe
'
:
false
,
'
auto_subscribe
'
:
false
,
'
play_sounds
'
:
false
,
'
play_sounds
'
:
false
,
...
@@ -101,9 +101,10 @@
...
@@ -101,9 +101,10 @@
'
password
'
:
'
secret
'
,
'
password
'
:
'
secret
'
,
'
debug
'
:
false
'
debug
'
:
false
},
settings
||
{}));
},
settings
||
{}));
converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
disable_effects
=
true
;
$
.
fx
.
off
=
true
;
$
.
fx
.
off
=
true
;
return
converse
;
return
_
converse
;
}
}
mock
.
initConverseWithPromises
=
function
(
spies
,
promise_names
,
settings
,
func
)
{
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