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
00e07825
Commit
00e07825
authored
Nov 03, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test that checks for delayed messages. Fixes #76
Messages older than one day do indicate it.
parent
d7d8948e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
1 deletion
+77
-1
spec/ChatBoxSpec.js
spec/ChatBoxSpec.js
+71
-1
tests/utils.js
tests/utils.js
+6
-0
No files found.
spec/ChatBoxSpec.js
View file @
00e07825
...
@@ -111,7 +111,7 @@
...
@@ -111,7 +111,7 @@
// messages
// messages
this
.
chatboxes
.
messageReceived
(
msg
);
this
.
chatboxes
.
messageReceived
(
msg
);
},
converse
));
},
converse
));
waits
(
5
00
);
waits
(
3
00
);
runs
(
$
.
proxy
(
function
()
{
runs
(
$
.
proxy
(
function
()
{
// Check that the chatbox and its view now exist
// Check that the chatbox and its view now exist
var
chatbox
=
this
.
chatboxes
.
get
(
sender_jid
);
var
chatbox
=
this
.
chatboxes
.
get
(
sender_jid
);
...
@@ -138,6 +138,76 @@
...
@@ -138,6 +138,76 @@
},
converse
));
},
converse
));
},
converse
));
},
converse
));
it
(
"
will indate when it has a time difference of more than a day between it and it's predecessor
"
,
$
.
proxy
(
function
()
{
var
contact_name
=
mock
.
cur_names
[
1
];
var
contact_jid
=
contact_name
.
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
utils
.
openChatBoxFor
(
contact_jid
);
utils
.
clearChatBoxMessages
(
contact_jid
);
var
one_day_ago
=
new
Date
(
new
Date
().
setDate
(
new
Date
().
getDate
()
-
1
));
var
message
=
'
This is a day old message
'
;
var
chatbox
=
this
.
chatboxes
.
get
(
contact_jid
);
var
chatboxview
=
this
.
chatboxesview
.
views
[
contact_jid
];
var
$chat_content
=
chatboxview
.
$el
.
find
(
'
.chat-content
'
);
var
msg_obj
;
var
msg_txt
;
var
sender_txt
;
this
.
chatboxes
.
messageReceived
(
$msg
({
from
:
contact_jid
,
to
:
this
.
connection
.
jid
,
type
:
'
chat
'
,
id
:
one_day_ago
.
getTime
()
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
delay
'
,
{
xmlns
:
'
urn:xmpp:delay
'
,
from
:
'
localhost
'
,
stamp
:
converse
.
toISOString
(
one_day_ago
)
})
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
()
);
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
msg_obj
=
chatbox
.
messages
.
models
[
0
];
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
contact_name
.
split
(
'
'
)[
0
]);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
true
);
msg_txt
=
$chat_content
.
find
(
'
.chat-message
'
).
find
(
'
.chat-message-content
'
).
text
();
expect
(
msg_txt
).
toEqual
(
message
);
sender_txt
=
$chat_content
.
find
(
'
span.chat-message-them
'
).
text
();
expect
(
sender_txt
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
message
=
'
This is a current message
'
;
this
.
chatboxes
.
messageReceived
(
$msg
({
from
:
contact_jid
,
to
:
this
.
connection
.
jid
,
type
:
'
chat
'
,
id
:
new
Date
().
getTime
()
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
()
);
// Check that there is a <time> element, with the required
// props.
var
$time
=
$chat_content
.
find
(
'
time
'
);
var
message_date
=
new
Date
();
message_date
.
setUTCHours
(
0
,
0
,
0
,
0
);
expect
(
$time
.
length
).
toEqual
(
1
);
expect
(
$time
.
attr
(
'
class
'
)).
toEqual
(
'
chat-date
'
);
expect
(
$time
.
attr
(
'
datetime
'
)).
toEqual
(
converse
.
toISOString
(
message_date
));
expect
(
$time
.
text
()).
toEqual
(
message_date
.
toString
().
substring
(
0
,
15
));
// Normal checks for the 2nd message
expect
(
chatbox
.
messages
.
length
).
toEqual
(
2
);
msg_obj
=
chatbox
.
messages
.
models
[
1
];
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
contact_name
.
split
(
'
'
)[
0
]);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
msg_txt
=
$chat_content
.
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-message-content
'
).
text
();
expect
(
msg_txt
).
toEqual
(
message
);
sender_txt
=
$chat_content
.
find
(
'
span.chat-message-them
'
).
last
().
text
();
expect
(
sender_txt
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
},
converse
));
it
(
"
can be sent from a chatbox, and will appear inside it
"
,
$
.
proxy
(
function
()
{
it
(
"
can be sent from a chatbox, and will appear inside it
"
,
$
.
proxy
(
function
()
{
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
utils
.
openChatBoxFor
(
contact_jid
);
utils
.
openChatBoxFor
(
contact_jid
);
...
...
tests/utils.js
View file @
00e07825
...
@@ -83,6 +83,12 @@
...
@@ -83,6 +83,12 @@
converse
.
rosterview
.
rosteritemviews
[
jid
].
openChat
(
mock
.
event
);
converse
.
rosterview
.
rosteritemviews
[
jid
].
openChat
(
mock
.
event
);
};
};
utils
.
clearChatBoxMessages
=
function
(
jid
)
{
var
view
=
converse
.
chatboxesview
.
views
[
jid
];
view
.
$el
.
find
(
'
.chat-content
'
).
empty
();
view
.
model
.
messages
.
reset
().
localStorage
.
_clear
();
};
utils
.
createNewChatRoom
=
function
(
room
,
nick
)
{
utils
.
createNewChatRoom
=
function
(
room
,
nick
)
{
var
controlbox_was_visible
=
$
(
"
#controlbox
"
).
is
(
'
:visible
'
);
var
controlbox_was_visible
=
$
(
"
#controlbox
"
).
is
(
'
:visible
'
);
utils
.
openControlBox
();
utils
.
openControlBox
();
...
...
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