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
461cebfe
Commit
461cebfe
authored
Jul 06, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for receiving message corrections
parent
8283d589
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
17 deletions
+53
-17
spec/messages.js
spec/messages.js
+53
-17
No files found.
spec/messages.js
View file @
461cebfe
...
@@ -7,13 +7,13 @@
...
@@ -7,13 +7,13 @@
],
factory
);
],
factory
);
}
(
this
,
function
(
$
,
jasmine
,
mock
,
test_utils
)
{
}
(
this
,
function
(
$
,
jasmine
,
mock
,
test_utils
)
{
"
use strict
"
;
"
use strict
"
;
var
_
=
converse
.
env
.
_
;
const
_
=
converse
.
env
.
_
;
var
$iq
=
converse
.
env
.
$iq
;
const
$iq
=
converse
.
env
.
$iq
;
var
$msg
=
converse
.
env
.
$msg
;
const
$msg
=
converse
.
env
.
$msg
;
var
Strophe
=
converse
.
env
.
Strophe
;
const
Strophe
=
converse
.
env
.
Strophe
;
var
Promise
=
converse
.
env
.
Promise
;
const
Promise
=
converse
.
env
.
Promise
;
var
moment
=
converse
.
env
.
moment
;
const
moment
=
converse
.
env
.
moment
;
var
u
=
converse
.
env
.
utils
;
const
u
=
converse
.
env
.
utils
;
describe
(
"
A Chat Message
"
,
function
()
{
describe
(
"
A Chat Message
"
,
function
()
{
...
@@ -27,14 +27,12 @@
...
@@ -27,14 +27,12 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
waitUntil
(
function
()
{
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
300
)
return
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group
'
).
length
;
},
300
)
.
then
(
function
()
{
.
then
(
function
()
{
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
,
'
emit
'
);
var
message
=
'
This is a received message
'
;
const
message
=
'
This is a received message
'
;
var
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
msg
=
$msg
({
const
msg
=
$msg
({
'
from
'
:
sender_jid
,
'
from
'
:
sender_jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
chat
'
,
'
type
'
:
'
chat
'
,
...
@@ -50,19 +48,19 @@
...
@@ -50,19 +48,19 @@
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
// Check that the chatbox and its view now exist
// Check that the chatbox and its view now exist
var
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
var
chatboxview
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
const
chatboxview
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
expect
(
chatbox
).
toBeDefined
();
expect
(
chatbox
).
toBeDefined
();
expect
(
chatboxview
).
toBeDefined
();
expect
(
chatboxview
).
toBeDefined
();
// Check that the message was received and check the message parameters
// Check that the message was received and check the message parameters
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
var
msg_obj
=
chatbox
.
messages
.
models
[
0
];
const
msg_obj
=
chatbox
.
messages
.
models
[
0
];
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
mock
.
cur_names
[
0
]);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
mock
.
cur_names
[
0
]);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
is_delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_delayed
'
)).
toEqual
(
false
);
// Now check that the message appears inside the chatbox in the DOM
// Now check that the message appears inside the chatbox in the DOM
var
chat_content
=
chatboxview
.
el
.
querySelector
(
'
.chat-content
'
);
const
chat_content
=
chatboxview
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg-text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg-text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg-time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
.chat-msg-time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
return
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
mock
.
cur_names
[
0
])
return
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
mock
.
cur_names
[
0
])
...
@@ -73,6 +71,44 @@
...
@@ -73,6 +71,44 @@
});
});
}));
}));
it
(
"
can be replaced with a correction
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
const
message
=
'
This is a received message
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
msg_id
=
u
.
getUniqueId
();
_converse
.
chatboxes
.
onMessage
(
$msg
({
'
from
'
:
sender_jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
chat
'
,
'
id
'
:
msg_id
,
}).
c
(
'
body
'
).
t
(
'
But soft, what light through yonder airlock breaks?
'
).
tree
());
var
chatboxview
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
expect
(
chatboxview
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
chatboxview
.
el
.
querySelector
(
'
.chat-msg-text
'
).
textContent
)
.
toBe
(
'
But soft, what light through yonder airlock breaks?
'
);
_converse
.
chatboxes
.
onMessage
(
$msg
({
'
from
'
:
sender_jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
chat
'
,
'
id
'
:
u
.
getUniqueId
(),
}).
c
(
'
body
'
).
t
(
'
But soft, what light through yonder window breaks?
'
).
up
()
.
c
(
'
replace
'
,
{
'
id
'
:
msg_id
,
'
xmlns
'
:
'
urn:xmpp:message-correct:0
'
}).
tree
());
expect
(
chatboxview
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
chatboxview
.
el
.
querySelector
(
'
.chat-msg-text
'
).
textContent
)
.
toBe
(
'
But soft, what light through yonder window breaks?
'
);
done
();
}));
describe
(
"
when a chatbox is opened for someone who is not in the roster
"
,
function
()
{
describe
(
"
when a chatbox is opened for someone who is not in the roster
"
,
function
()
{
it
(
"
the VCard for that user is fetched and the chatbox updated with the results
"
,
it
(
"
the VCard for that user is fetched and the chatbox updated with the results
"
,
...
...
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