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
0fdf2862
Commit
0fdf2862
authored
Jul 03, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for forwarded carbon messages.
parent
c2ccb2c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
spec/chatbox.js
spec/chatbox.js
+41
-0
No files found.
spec/chatbox.js
View file @
0fdf2862
...
...
@@ -473,6 +473,47 @@
"
Ignore incoming message intended for a different resource: dummy@localhost/some-other-resource
"
,
"
info
"
);
});
it
(
"
can be a carbon message, as defined in XEP-0280
"
,
function
()
{
// Send a message from a different resource
spyOn
(
converse
,
'
log
'
);
var
msgtext
=
'
This is a carbon message
'
;
var
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
msg
=
$msg
({
'
from
'
:
converse
.
bare_jid
,
'
id
'
:
(
new
Date
()).
getTime
(),
'
to
'
:
converse
.
connection
.
jid
,
'
type
'
:
'
chat
'
,
'
xmlns
'
:
'
jabber:client
'
}).
c
(
'
received
'
,
{
'
xmlns
'
:
'
urn:xmpp:carbons:2
'
})
.
c
(
'
forwarded
'
,
{
'
xmlns
'
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
message
'
,
{
'
xmlns
'
:
'
jabber:client
'
,
'
from
'
:
sender_jid
,
'
to
'
:
converse
.
bare_jid
+
'
/another-resource
'
,
'
type
'
:
'
chat
'
}).
c
(
'
body
'
).
t
(
msgtext
).
tree
();
converse
.
chatboxes
.
onMessage
(
msg
);
// Check that the chatbox and its view now exist
var
chatbox
=
converse
.
chatboxes
.
get
(
sender_jid
);
var
chatboxview
=
converse
.
chatboxviews
.
get
(
sender_jid
);
expect
(
chatbox
).
toBeDefined
();
expect
(
chatboxview
).
toBeDefined
();
// Check that the message was received and check the message parameters
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
var
msg_obj
=
chatbox
.
messages
.
models
[
0
];
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
msgtext
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
mock
.
cur_names
[
1
].
split
(
'
'
)[
0
]);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
// Now check that the message appears inside the chatbox in the DOM
var
$chat_content
=
chatboxview
.
$el
.
find
(
'
.chat-content
'
);
var
msg_txt
=
$chat_content
.
find
(
'
.chat-message
'
).
find
(
'
.chat-message-content
'
).
text
();
expect
(
msg_txt
).
toEqual
(
msgtext
);
var
sender_txt
=
$chat_content
.
find
(
'
span.chat-message-them
'
).
text
();
expect
(
sender_txt
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
});
it
(
"
received for a minimized chat box will increment a counter on its header
"
,
$
.
proxy
(
function
()
{
var
contact_name
=
mock
.
cur_names
[
0
];
var
contact_jid
=
contact_name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
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