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
c594e5a1
Commit
c594e5a1
authored
Jun 01, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new test for trimmed chats
parent
9d96b1bf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
10 deletions
+46
-10
converse.js
converse.js
+14
-10
spec/chatbox.js
spec/chatbox.js
+32
-0
No files found.
converse.js
View file @
c594e5a1
...
...
@@ -2666,15 +2666,7 @@
initialize
:
function
()
{
this
.
model
.
on
(
"
change:trimmed
"
,
function
(
item
)
{
var
view
;
if
(
item
.
get
(
'
trimmed
'
))
{
view
=
new
converse
.
TrimmedChatBoxView
({
model
:
item
});
this
.
$
(
'
.box-flyout
'
).
append
(
view
.
render
());
this
.
add
(
item
.
get
(
'
id
'
),
view
);
}
else
{
view
=
this
.
get
(
item
.
get
(
'
id
'
));
view
.
restore
();
}
this
.
onChanged
(
item
);
},
this
);
},
...
...
@@ -2682,7 +2674,7 @@
return
this
.
$el
;
},
_ensureElement
:
function
()
{
_ensureElement
:
function
()
{
/* Override method from backbone.js
* Make sure that the el and $el attributes point to a DOM snippet
* from src/templates/trimmed_chats.html
...
...
@@ -2694,6 +2686,18 @@
this
.
setElement
(
_
.
result
(
this
,
'
el
'
),
false
);
}
},
onChanged
:
function
(
item
)
{
var
view
;
if
(
item
.
get
(
'
trimmed
'
))
{
view
=
new
converse
.
TrimmedChatBoxView
({
model
:
item
});
this
.
$
(
'
.box-flyout
'
).
append
(
view
.
render
());
this
.
add
(
item
.
get
(
'
id
'
),
view
);
}
else
{
view
=
this
.
get
(
item
.
get
(
'
id
'
));
view
.
restore
();
}
}
});
this
.
RosterItem
=
Backbone
.
Model
.
extend
({
...
...
spec/chatbox.js
View file @
c594e5a1
...
...
@@ -56,6 +56,38 @@
}
},
converse
));
it
(
"
can be trimmed to conserve space
"
,
$
.
proxy
(
function
()
{
var
i
,
$el
,
click
,
jid
,
view
,
chatboxview
;
// openControlBox was called earlier, so the controlbox is
// visible, but no other chat boxes have been created.
var
trimmed_chatboxes
=
converse
.
chatboxviews
.
trimmed_chatboxes_view
;
expect
(
this
.
chatboxes
.
length
).
toEqual
(
1
);
spyOn
(
this
.
chatboxviews
,
'
trimChats
'
);
spyOn
(
trimmed_chatboxes
,
'
onChanged
'
).
andCallThrough
();
expect
(
$
(
"
#conversejs .chatbox
"
).
length
).
toBe
(
1
);
// Controlbox is open
var
online_contacts
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact
'
).
find
(
'
a.open-chat
'
);
for
(
i
=
0
;
i
<
online_contacts
.
length
;
i
++
)
{
$el
=
$
(
online_contacts
[
i
]);
jid
=
$el
.
text
().
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
view
=
this
.
rosterview
.
get
(
jid
);
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
$el
.
click
();
expect
(
this
.
chatboxviews
.
trimChats
).
toHaveBeenCalled
();
chatboxview
=
this
.
chatboxviews
.
get
(
jid
);
spyOn
(
chatboxview
,
'
trim
'
).
andCallThrough
();
chatboxview
.
model
.
set
({
'
trimmed
'
:
true
});
expect
(
trimmed_chatboxes
.
onChanged
).
toHaveBeenCalled
();
expect
(
chatboxview
.
trim
).
toHaveBeenCalled
();
trimmedview
=
trimmed_chatboxes
.
get
(
jid
);
expect
(
trimmedview
.
$el
.
is
(
"
:visible
"
)).
toBeTruthy
();
}
},
converse
));
it
(
"
is focused if its already open and you click on its corresponding roster item
"
,
$
.
proxy
(
function
()
{
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
i
,
$el
,
click
,
jid
,
view
,
chatboxview
,
chatbox
;
...
...
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