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
1bea7a1a
Commit
1bea7a1a
authored
Jun 16, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix trimming/minimize tests broken after recent refactor
parent
c9d7e17a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
32 deletions
+31
-32
spec/chatbox.js
spec/chatbox.js
+29
-30
spec/controlbox.js
spec/controlbox.js
+2
-2
No files found.
spec/chatbox.js
View file @
1bea7a1a
...
...
@@ -25,8 +25,6 @@
runs
(
function
()
{
utils
.
openContactsPanel
();
});
waits
(
250
);
runs
(
function
()
{});
});
it
(
"
is created when you click on a roster item
"
,
$
.
proxy
(
function
()
{
...
...
@@ -57,13 +55,14 @@
},
converse
));
it
(
"
can be trimmed to conserve space
"
,
$
.
proxy
(
function
()
{
var
i
,
$el
,
click
,
jid
,
key
,
view
,
chatboxview
;
var
i
,
$el
,
click
,
jid
,
key
,
view
,
chatbox
,
chatbox
view
;
// 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
;
var
trimmed_chatboxes
=
converse
.
minimized_chats
;
expect
(
this
.
chatboxes
.
length
).
toEqual
(
1
);
spyOn
(
this
.
chatboxviews
,
'
trimChats
'
);
spyOn
(
trimmed_chatboxes
,
'
onChanged
'
).
andCallThrough
();
spyOn
(
trimmed_chatboxes
,
'
addChat
'
).
andCallThrough
();
spyOn
(
trimmed_chatboxes
,
'
removeChat
'
).
andCallThrough
();
expect
(
$
(
"
#conversejs .chatbox
"
).
length
).
toBe
(
1
);
// Controlbox is open
// Test that they can be trimmed
...
...
@@ -72,33 +71,34 @@
$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
,
'
hide
'
).
andCallThrough
();
chatboxview
.
model
.
set
({
'
minimized
'
:
true
});
expect
(
trimmed_chatboxes
.
onChanged
).
toHaveBeenCalled
();
expect
(
trimmed_chatboxes
.
addChat
).
toHaveBeenCalled
();
expect
(
chatboxview
.
hide
).
toHaveBeenCalled
();
trimmedview
=
trimmed_chatboxes
.
get
(
jid
);
expect
(
trimmedview
.
$el
.
is
(
"
:visible
"
)).
toBeTruthy
();
}
// Test that they can be maximized again
var
chatboxviews
=
this
.
chatboxviews
.
getAll
();
var
keys
=
_
.
keys
(
chatboxviews
);
for
(
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
key
=
keys
[
i
];
if
(
key
===
'
controlbox
'
)
{
continue
;
}
chatboxview
=
chatboxviews
[
key
];
runs
(
$
.
proxy
(
function
()
{
var
key
=
this
.
chatboxviews
.
keys
()[
1
];
trimmedview
=
trimmed_chatboxes
.
get
(
key
);
spyOn
(
chatboxview
,
'
maximize
'
).
andCallThrough
();
chatbox
=
trimmedview
.
model
;
spyOn
(
chatbox
,
'
maximize
'
).
andCallThrough
();
spyOn
(
trimmedview
,
'
restore
'
).
andCallThrough
();
trimmedview
.
delegateEvents
();
trimmedview
.
$
(
"
a.restore-chat
"
).
click
();
expect
(
trimmed_chatboxes
.
onChanged
).
toHaveBeenCalled
();
expect
(
chatboxview
.
maximize
).
toHaveBeenCalled
();
}
},
this
));
waits
(
250
);
runs
(
$
.
proxy
(
function
()
{
expect
(
trimmedview
.
restore
).
toHaveBeenCalled
();
expect
(
chatbox
.
maximize
).
toHaveBeenCalled
();
expect
(
this
.
chatboxviews
.
trimChats
).
toHaveBeenCalled
();
},
this
));
},
converse
));
it
(
"
is focused if its already open and you click on its corresponding roster item
"
,
$
.
proxy
(
function
()
{
...
...
@@ -184,18 +184,17 @@
it
(
"
can be minimized by clicking a DOM element with class 'toggle-chatbox-button'
"
,
function
()
{
var
chatbox
=
utils
.
openChatBoxes
(
1
)[
0
],
chatview
=
this
.
chatboxviews
.
get
(
chatbox
.
get
(
'
jid
'
)),
trimmed_chatboxes
=
this
.
chatboxviews
.
trimmed_chatboxes_view
;
spyOn
(
chatview
,
'
maximize
'
).
andCallThrough
()
;
trimmed_chatboxes
=
this
.
minimized_chats
,
trimmedview
;
spyOn
(
chatview
,
'
minimize
'
).
andCallThrough
();
spyOn
(
converse
,
'
emit
'
);
spyOn
(
trimmed_chatboxes
,
'
onChanged
'
).
andCallThrough
();
// We need to rebind all events otherwise our spy won't be called
chatview
.
delegateEvents
();
runs
(
function
()
{
chatview
.
$el
.
find
(
'
.toggle-chatbox-button
'
).
click
();
});
waits
(
50
);
waits
(
2
50
);
runs
(
function
()
{
expect
(
chatview
.
minimize
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onChatBoxMinimized
'
,
jasmine
.
any
(
Object
));
...
...
@@ -203,14 +202,14 @@
expect
(
chatview
.
$el
.
is
(
'
:visible
'
)).
toBeFalsy
();
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
chatview
.
$el
.
find
(
'
.toggle-chatbox-button
'
).
click
();
trimmedview
=
trimmed_chatboxes
.
get
(
chatview
.
model
.
get
(
'
id
'
));
spyOn
(
trimmedview
,
'
restore
'
).
andCallThrough
();
trimmedview
.
delegateEvents
();
trimmedview
.
$
(
"
a.restore-chat
"
).
click
();
});
waits
(
50
);
waits
(
2
50
);
runs
(
function
()
{
expect
(
trimmed_chatboxes
.
onChanged
).
toHaveBeenCalled
();
expect
(
chatview
.
maximize
).
toHaveBeenCalled
();
expect
(
trimmedview
.
restore
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onChatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
chatview
.
$el
.
find
(
'
.chat-body
'
).
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatview
.
$el
.
find
(
'
.toggle-chatbox-button
'
).
hasClass
(
'
icon-minus
'
)).
toBeTruthy
();
...
...
@@ -488,7 +487,7 @@
},
converse
));
waits
(
50
);
runs
(
$
.
proxy
(
function
()
{
var
trimmed_chatboxes
=
this
.
chatboxviews
.
trimmed_chatboxes_view
;
var
trimmed_chatboxes
=
this
.
minimized_chats
;
var
trimmedview
=
trimmed_chatboxes
.
get
(
contact_jid
);
var
$count
=
trimmedview
.
$el
.
find
(
'
.chat-head-message-count
'
);
expect
(
trimmedview
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
...
...
@@ -507,7 +506,7 @@
},
converse
));
waits
(
50
);
runs
(
$
.
proxy
(
function
()
{
var
trimmed_chatboxes
=
this
.
chatboxviews
.
trimmed_chatboxes_view
;
var
trimmed_chatboxes
=
this
.
minimized_chats
;
var
trimmedview
=
trimmed_chatboxes
.
get
(
contact_jid
);
var
$count
=
trimmedview
.
$el
.
find
(
'
.chat-head-message-count
'
);
expect
(
trimmedview
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
...
...
@@ -518,7 +517,7 @@
},
converse
));
waits
(
50
);
runs
(
$
.
proxy
(
function
()
{
var
trimmed_chatboxes
=
this
.
chatboxviews
.
trimmed_chatboxes_view
;
var
trimmed_chatboxes
=
this
.
minimized_chats
;
var
trimmedview
=
trimmed_chatboxes
.
get
(
contact_jid
);
var
$count
=
trimmedview
.
$el
.
find
(
'
.chat-head-message-count
'
);
expect
(
trimmedview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
...
...
spec/controlbox.js
View file @
1bea7a1a
...
...
@@ -14,7 +14,7 @@
});
});
it
(
"
can be opened by clicking a DOM element with class 'toggle-
online-users
'
"
,
$
.
proxy
(
function
()
{
it
(
"
can be opened by clicking a DOM element with class 'toggle-
controlbox
'
"
,
$
.
proxy
(
function
()
{
runs
(
function
()
{
utils
.
closeControlBox
();
});
...
...
@@ -28,7 +28,7 @@
spyOn
(
converse
,
'
emit
'
);
// Redelegate so that the spies are now registered as the event handlers (specifically for 'onClick')
this
.
controlboxtoggle
.
delegateEvents
();
$
(
'
.toggle-
online-users
'
).
click
();
$
(
'
.toggle-
controlbox
'
).
click
();
}.
bind
(
converse
));
waits
(
250
);
runs
(
function
()
{
...
...
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