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
c25f33b1
Commit
c25f33b1
authored
Jul 04, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add proper separation between controlbox tests
parent
5034ae33
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
42 deletions
+87
-42
spec/chatbox.js
spec/chatbox.js
+2
-2
spec/controlbox.js
spec/controlbox.js
+55
-32
spec/minchats.js
spec/minchats.js
+1
-1
tests/utils.js
tests/utils.js
+29
-7
No files found.
spec/chatbox.js
View file @
c25f33b1
...
...
@@ -15,7 +15,7 @@
utils
.
removeControlBox
();
converse
.
roster
.
browserStorage
.
_clear
();
utils
.
initConverse
();
utils
.
createC
urrentC
ontacts
();
utils
.
createContacts
();
utils
.
openControlBox
();
utils
.
openContactsPanel
();
});
...
...
@@ -694,7 +694,7 @@
utils
.
removeControlBox
();
converse
.
roster
.
browserStorage
.
_clear
();
utils
.
initConverse
();
utils
.
createC
urrentC
ontacts
();
utils
.
createContacts
();
utils
.
openControlBox
();
utils
.
openContactsPanel
();
});
...
...
spec/controlbox.js
View file @
c25f33b1
...
...
@@ -106,27 +106,30 @@
},
converse
,
mock
,
utils
));
describe
(
"
The Contacts Roster
"
,
$
.
proxy
(
function
(
mock
,
utils
)
{
// FIXME: These tests are dependent on being run in order and cannot be
// run independently
describe
(
"
Pending Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
utils
.
openControlBox
();
converse
.
rosterview
.
model
.
reset
();
utils
.
createContacts
(
'
pending
'
).
openControlBox
();
});
waits
(
50
);
runs
(
function
()
{
utils
.
openContactsPanel
();
});
waits
(
50
);
runs
(
function
()
{});
});
},
converse
));
it
(
"
do not have a heading if there aren't any
"
,
$
.
proxy
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
css
(
'
display
'
)).
toEqual
(
'
none
'
);
},
converse
));
it
(
"
will have their own heading once they have been added
"
,
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
css
(
'
display
'
)).
toEqual
(
'
block
'
);
},
converse
));
it
(
"
can be added to the roster
"
,
$
.
proxy
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
// We want to manually create users so that we can spy
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
runs
(
$
.
proxy
(
function
()
{
...
...
@@ -155,26 +158,28 @@
spyOn
(
this
.
connection
.
roster
,
'
unauthorize
'
);
spyOn
(
this
.
rosterview
.
model
,
'
remove
'
).
andCallThrough
();
runs
(
$
.
proxy
(
function
()
{
view
.
$el
.
find
(
'
.remove-xmpp-contact
'
).
click
();
},
converse
));
waits
(
250
);
runs
(
$
.
proxy
(
function
()
{
expect
(
window
.
confirm
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
roster
.
remove
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
roster
.
unauthorize
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
model
.
remove
).
toHaveBeenCalled
();
// The element must now be detached from the DOM.
expect
(
view
.
$el
.
closest
(
'
html
'
).
length
).
toBeFalsy
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
},
converse
));
view
.
$el
.
find
(
'
.remove-xmpp-contact
'
).
click
();
expect
(
window
.
confirm
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
roster
.
remove
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
roster
.
unauthorize
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
model
.
remove
).
toHaveBeenCalled
();
// The element must now be detached from the DOM.
expect
(
view
.
$el
.
closest
(
'
html
'
).
length
).
toBeFalsy
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
},
converse
));
it
(
"
will lose their own heading once the last one has been removed
"
,
$
.
proxy
(
function
()
{
var
view
;
spyOn
(
window
,
'
confirm
'
).
andReturn
(
true
);
for
(
i
=
0
;
i
<
mock
.
pend_names
.
length
;
i
++
)
{
view
=
this
.
rosterview
.
get
(
mock
.
pend_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
);
view
.
$el
.
find
(
'
.remove-xmpp-contact
'
).
click
();
}
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
},
converse
));
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
// We want to manually create users so that we can spy
var
i
,
t
,
is_last
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
...
...
@@ -195,21 +200,13 @@
}
},
converse
));
it
(
"
will have their own heading once they have been added
"
,
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
css
(
'
display
'
)).
toEqual
(
'
block
'
);
},
converse
));
},
converse
));
describe
(
"
Existing Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
utils
.
createCurrentContacts
();
});
waits
(
50
);
runs
(
function
()
{
utils
.
openControlBox
();
utils
.
createContacts
().
openControlBox
();
});
waits
(
50
);
runs
(
function
()
{
...
...
@@ -393,13 +390,26 @@
},
converse
));
describe
(
"
Requesting Contacts
"
,
$
.
proxy
(
function
()
{
// by default the dts are hidden from css class and only later they will be hidden
// by jQuery therefore for the first check we will see if visible instead of none
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
utils
.
createContacts
(
'
requesting
'
).
openControlBox
();
});
waits
(
50
);
runs
(
function
()
{
utils
.
openContactsPanel
();
});
},
converse
));
it
(
"
do not have a heading if there aren't any
"
,
$
.
proxy
(
function
()
{
// by default the dts are hidden from css class and only later they will be hidden
// by jQuery therefore for the first check we will see if visible instead of none
converse
.
rosterview
.
model
.
reset
();
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contact-requests
'
).
is
(
'
:visible
'
)).
toEqual
(
false
);
},
converse
));
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
// We want to manually create users so that we can spy
var
i
,
t
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
...
...
@@ -458,11 +468,24 @@
expect
(
this
.
connection
.
roster
.
unauthorize
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
// There should now be one less contact
expect
(
this
.
roster
.
length
).
toEqual
(
mock
.
num_contacts
-
1
);
expect
(
this
.
roster
.
length
).
toEqual
(
mock
.
req_names
.
length
-
1
);
},
converse
));
},
converse
));
describe
(
"
All Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
converse
.
rosterview
.
model
.
browserStorage
.
_clear
();
utils
.
createContacts
(
'
all
'
).
openControlBox
();
});
waits
(
50
);
runs
(
function
()
{
utils
.
openContactsPanel
();
});
},
converse
));
it
(
"
are saved to, and can be retrieved from, browserStorage
"
,
$
.
proxy
(
function
()
{
var
new_attrs
,
old_attrs
,
attrs
,
old_roster
;
var
num_contacts
=
this
.
roster
.
length
;
...
...
spec/minchats.js
View file @
c25f33b1
...
...
@@ -15,7 +15,7 @@
utils
.
removeControlBox
();
converse
.
roster
.
browserStorage
.
_clear
();
utils
.
initConverse
();
utils
.
createC
urrentC
ontacts
();
utils
.
createContacts
();
utils
.
openControlBox
();
utils
.
openContactsPanel
();
converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
...
...
tests/utils.js
View file @
c25f33b1
...
...
@@ -92,6 +92,7 @@
utils
.
clearBrowserStorage
=
function
()
{
window
.
localStorage
.
clear
();
window
.
sessionStorage
.
clear
();
return
this
;
};
utils
.
clearChatBoxMessages
=
function
(
jid
)
{
...
...
@@ -101,16 +102,37 @@
view
.
model
.
messages
.
browserStorage
.
_clear
();
};
utils
.
createC
urrentContacts
=
function
(
)
{
utils
.
createC
ontacts
=
function
(
type
)
{
// Create current (as opposed to requesting or pending) contacts
// for the user's roster.
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
var
names
;
if
(
type
===
'
requesting
'
)
{
names
=
mock
.
req_names
;
subscription
=
'
none
'
;
requesting
=
true
;
ask
=
null
;
}
else
if
(
type
===
'
pending
'
)
{
names
=
mock
.
pend_names
;
subscription
=
'
none
'
;
requesting
=
false
;
ask
=
'
subscribe
'
;
}
else
if
(
type
===
'
all
'
)
{
this
.
createContacts
().
createContacts
(
'
request
'
).
createContacts
(
'
pending
'
);
return
this
;
}
else
{
names
=
mock
.
cur_names
;
subscription
=
'
both
'
;
requesting
=
false
;
ask
=
null
;
}
for
(
i
=
0
;
i
<
names
.
length
;
i
++
)
{
converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
both
'
,
ask
:
null
,
fullname
:
mock
.
cur_names
[
i
],
is_last
:
i
===
(
mock
.
cur_names
.
length
-
1
)
ask
:
ask
,
fullname
:
names
[
i
],
is_last
:
i
===
(
names
.
length
-
1
),
jid
:
names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
requesting
:
requesting
,
subscription
:
subscription
});
}
return
this
;
...
...
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