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 @@
...
@@ -15,7 +15,7 @@
utils
.
removeControlBox
();
utils
.
removeControlBox
();
converse
.
roster
.
browserStorage
.
_clear
();
converse
.
roster
.
browserStorage
.
_clear
();
utils
.
initConverse
();
utils
.
initConverse
();
utils
.
createC
urrentC
ontacts
();
utils
.
createContacts
();
utils
.
openControlBox
();
utils
.
openControlBox
();
utils
.
openContactsPanel
();
utils
.
openContactsPanel
();
});
});
...
@@ -694,7 +694,7 @@
...
@@ -694,7 +694,7 @@
utils
.
removeControlBox
();
utils
.
removeControlBox
();
converse
.
roster
.
browserStorage
.
_clear
();
converse
.
roster
.
browserStorage
.
_clear
();
utils
.
initConverse
();
utils
.
initConverse
();
utils
.
createC
urrentC
ontacts
();
utils
.
createContacts
();
utils
.
openControlBox
();
utils
.
openControlBox
();
utils
.
openContactsPanel
();
utils
.
openContactsPanel
();
});
});
...
...
spec/controlbox.js
View file @
c25f33b1
...
@@ -106,27 +106,30 @@
...
@@ -106,27 +106,30 @@
},
converse
,
mock
,
utils
));
},
converse
,
mock
,
utils
));
describe
(
"
The Contacts Roster
"
,
$
.
proxy
(
function
(
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
()
{
describe
(
"
Pending Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
runs
(
function
()
{
utils
.
openControlBox
();
converse
.
rosterview
.
model
.
reset
();
utils
.
createContacts
(
'
pending
'
).
openControlBox
();
});
});
waits
(
50
);
waits
(
50
);
runs
(
function
()
{
runs
(
function
()
{
utils
.
openContactsPanel
();
utils
.
openContactsPanel
();
});
});
waits
(
50
);
},
converse
));
runs
(
function
()
{});
});
it
(
"
do not have a heading if there aren't any
"
,
$
.
proxy
(
function
()
{
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
'
);
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
css
(
'
display
'
)).
toEqual
(
'
none
'
);
},
converse
));
},
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
()
{
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
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
runs
(
$
.
proxy
(
function
()
{
runs
(
$
.
proxy
(
function
()
{
...
@@ -155,26 +158,28 @@
...
@@ -155,26 +158,28 @@
spyOn
(
this
.
connection
.
roster
,
'
unauthorize
'
);
spyOn
(
this
.
connection
.
roster
,
'
unauthorize
'
);
spyOn
(
this
.
rosterview
.
model
,
'
remove
'
).
andCallThrough
();
spyOn
(
this
.
rosterview
.
model
,
'
remove
'
).
andCallThrough
();
runs
(
$
.
proxy
(
function
()
{
view
.
$el
.
find
(
'
.remove-xmpp-contact
'
).
click
();
view
.
$el
.
find
(
'
.remove-xmpp-contact
'
).
click
();
expect
(
window
.
confirm
).
toHaveBeenCalled
();
},
converse
));
expect
(
this
.
connection
.
roster
.
remove
).
toHaveBeenCalled
();
waits
(
250
);
expect
(
this
.
connection
.
roster
.
unauthorize
).
toHaveBeenCalled
();
runs
(
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
model
.
remove
).
toHaveBeenCalled
();
expect
(
window
.
confirm
).
toHaveBeenCalled
();
// The element must now be detached from the DOM.
expect
(
this
.
connection
.
roster
.
remove
).
toHaveBeenCalled
();
expect
(
view
.
$el
.
closest
(
'
html
'
).
length
).
toBeFalsy
();
expect
(
this
.
connection
.
roster
.
unauthorize
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
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
));
},
converse
));
},
converse
));
it
(
"
will lose their own heading once the last one has been removed
"
,
$
.
proxy
(
function
()
{
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
();
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
is
(
'
:visible
'
)).
toBeFalsy
();
},
converse
));
},
converse
));
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
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
;
var
i
,
t
,
is_last
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
...
@@ -195,21 +200,13 @@
...
@@ -195,21 +200,13 @@
}
}
},
converse
));
},
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
));
},
converse
));
describe
(
"
Existing Contacts
"
,
$
.
proxy
(
function
()
{
describe
(
"
Existing Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
runs
(
function
()
{
converse
.
rosterview
.
model
.
reset
();
converse
.
rosterview
.
model
.
reset
();
utils
.
createCurrentContacts
();
utils
.
createContacts
().
openControlBox
();
});
waits
(
50
);
runs
(
function
()
{
utils
.
openControlBox
();
});
});
waits
(
50
);
waits
(
50
);
runs
(
function
()
{
runs
(
function
()
{
...
@@ -393,13 +390,26 @@
...
@@ -393,13 +390,26 @@
},
converse
));
},
converse
));
describe
(
"
Requesting Contacts
"
,
$
.
proxy
(
function
()
{
describe
(
"
Requesting Contacts
"
,
$
.
proxy
(
function
()
{
// by default the dts are hidden from css class and only later they will be hidden
beforeEach
(
$
.
proxy
(
function
()
{
// by jQuery therefore for the first check we will see if visible instead of none
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
()
{
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
);
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contact-requests
'
).
is
(
'
:visible
'
)).
toEqual
(
false
);
},
converse
));
},
converse
));
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
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
;
var
i
,
t
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
...
@@ -458,11 +468,24 @@
...
@@ -458,11 +468,24 @@
expect
(
this
.
connection
.
roster
.
unauthorize
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
roster
.
unauthorize
).
toHaveBeenCalled
();
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
expect
(
converse
.
emit
).
toHaveBeenCalledWith
(
'
onRosterViewUpdated
'
);
// There should now be one less contact
// 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
));
},
converse
));
},
converse
));
describe
(
"
All Contacts
"
,
$
.
proxy
(
function
()
{
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
()
{
it
(
"
are saved to, and can be retrieved from, browserStorage
"
,
$
.
proxy
(
function
()
{
var
new_attrs
,
old_attrs
,
attrs
,
old_roster
;
var
new_attrs
,
old_attrs
,
attrs
,
old_roster
;
var
num_contacts
=
this
.
roster
.
length
;
var
num_contacts
=
this
.
roster
.
length
;
...
...
spec/minchats.js
View file @
c25f33b1
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
utils
.
removeControlBox
();
utils
.
removeControlBox
();
converse
.
roster
.
browserStorage
.
_clear
();
converse
.
roster
.
browserStorage
.
_clear
();
utils
.
initConverse
();
utils
.
initConverse
();
utils
.
createC
urrentC
ontacts
();
utils
.
createContacts
();
utils
.
openControlBox
();
utils
.
openControlBox
();
utils
.
openContactsPanel
();
utils
.
openContactsPanel
();
converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
...
...
tests/utils.js
View file @
c25f33b1
...
@@ -92,6 +92,7 @@
...
@@ -92,6 +92,7 @@
utils
.
clearBrowserStorage
=
function
()
{
utils
.
clearBrowserStorage
=
function
()
{
window
.
localStorage
.
clear
();
window
.
localStorage
.
clear
();
window
.
sessionStorage
.
clear
();
window
.
sessionStorage
.
clear
();
return
this
;
};
};
utils
.
clearChatBoxMessages
=
function
(
jid
)
{
utils
.
clearChatBoxMessages
=
function
(
jid
)
{
...
@@ -101,16 +102,37 @@
...
@@ -101,16 +102,37 @@
view
.
model
.
messages
.
browserStorage
.
_clear
();
view
.
model
.
messages
.
browserStorage
.
_clear
();
};
};
utils
.
createC
urrentContacts
=
function
(
)
{
utils
.
createC
ontacts
=
function
(
type
)
{
// Create current (as opposed to requesting or pending) contacts
// Create current (as opposed to requesting or pending) contacts
// for the user's roster.
// 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
({
converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
ask
:
ask
,
subscription
:
'
both
'
,
fullname
:
names
[
i
],
ask
:
null
,
is_last
:
i
===
(
names
.
length
-
1
),
fullname
:
mock
.
cur_names
[
i
],
jid
:
names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
is_last
:
i
===
(
mock
.
cur_names
.
length
-
1
)
requesting
:
requesting
,
subscription
:
subscription
});
});
}
}
return
this
;
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