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
29a6e1d9
Commit
29a6e1d9
authored
Apr 14, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move requesting contacts after pending/current.
parent
c13bd1e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
40 deletions
+52
-40
spec/MainSpec.js
spec/MainSpec.js
+52
-40
No files found.
spec/MainSpec.js
View file @
29a6e1d9
...
@@ -52,10 +52,11 @@
...
@@ -52,10 +52,11 @@
this
.
prebind
=
true
;
this
.
prebind
=
true
;
this
.
onConnected
(
mock_connection
);
this
.
onConnected
(
mock_connection
);
this
.
animate
=
false
;
// don't use animations
// The timeout is used to slow down the tests so that one can see
// The timeout is used to slow down the tests so that one can see
// visually what is happening in the page.
// visually what is happening in the page.
var
timeout
=
20
0
;
var
timeout
=
0
;
var
sleep
=
function
(
delay
)
{
var
sleep
=
function
(
delay
)
{
// Yes this is blocking and stupid, but these are tests and this is
// Yes this is blocking and stupid, but these are tests and this is
// the easiest way to delay execution without having to use
// the easiest way to delay execution without having to use
...
@@ -77,61 +78,35 @@
...
@@ -77,61 +78,35 @@
expect
(
this
.
toggleControlBox
).
toHaveBeenCalled
();
expect
(
this
.
toggleControlBox
).
toHaveBeenCalled
();
},
xmppchat
));
},
xmppchat
));
// 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
it
(
"
hides the requesting contacts heading if there aren't any
"
,
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contact-requests
'
).
is
(
'
:visible
'
)).
toEqual
(
false
);
},
xmppchat
));
it
(
"
can add requesting contacts, and they should be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
sleep
(
timeout
);
var
i
,
t
;
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
spyOn
(
this
,
'
showControlBox
'
).
andCallThrough
();
for
(
i
=
0
;
i
<
req_names
.
length
;
i
++
)
{
this
.
roster
.
create
({
jid
:
req_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
none
'
,
ask
:
'
request
'
,
fullname
:
req_names
[
i
],
is_last
:
i
==
(
req_names
.
length
-
1
)
});
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contact-requests
'
).
siblings
(
'
dd.requesting-xmpp-contact
'
).
text
().
replace
(
/AcceptDecline/g
,
''
);
expect
(
t
).
toEqual
(
req_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
// When a requesting contact is added, the controlbox must
// be opened.
expect
(
this
.
showControlBox
).
toHaveBeenCalled
();
sleep
(
timeout
);
}
},
xmppchat
));
it
(
"
shows the requesting contacts heading after they have been added
"
,
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contact-requests
'
).
css
(
'
display
'
)).
toEqual
(
'
block
'
);
},
xmppchat
));
it
(
"
hides the pending contacts heading if there aren't any
"
,
$
.
proxy
(
function
()
{
it
(
"
hides the pending contacts heading if there aren't any
"
,
$
.
proxy
(
function
()
{
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
'
);
},
xmppchat
));
},
xmppchat
));
it
(
"
can add pending contacts, and they should be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
it
(
"
can add pending contacts, and they should be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
var
i
,
t
;
var
i
,
t
,
is_last
;
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
for
(
i
=
0
;
i
<
pend_names
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
pend_names
.
length
;
i
++
)
{
is_last
=
i
==
(
pend_names
.
length
-
1
);
this
.
roster
.
create
({
this
.
roster
.
create
({
jid
:
pend_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
jid
:
pend_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
none
'
,
subscription
:
'
none
'
,
ask
:
'
subscribe
'
,
ask
:
'
subscribe
'
,
fullname
:
pend_names
[
i
],
fullname
:
pend_names
[
i
],
is_last
:
i
==
(
pend_names
-
1
)
is_last
:
i
s_last
});
});
// For performance reasons, the roster should only be shown once
// the last contact has been added.
if
(
is_last
)
{
expect
(
this
.
rosterview
.
$el
.
is
(
'
:visible
'
)).
toEqual
(
true
);
}
else
{
expect
(
this
.
rosterview
.
$el
.
is
(
'
:visible
'
)).
toEqual
(
false
);
}
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
siblings
(
'
dd.pending-xmpp-contact
'
).
text
();
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#pending-xmpp-contacts
'
).
siblings
(
'
dd.pending-xmpp-contact
'
).
text
();
expect
(
t
).
toEqual
(
pend_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
expect
(
t
).
toEqual
(
pend_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
sleep
(
timeout
);
}
}
sleep
(
timeout
);
},
xmppchat
));
},
xmppchat
));
it
(
"
shows the pending contacts heading after they have been added
"
,
$
.
proxy
(
function
()
{
it
(
"
shows the pending contacts heading after they have been added
"
,
$
.
proxy
(
function
()
{
...
@@ -151,20 +126,57 @@
...
@@ -151,20 +126,57 @@
subscription
:
'
both
'
,
subscription
:
'
both
'
,
ask
:
null
,
ask
:
null
,
fullname
:
cur_names
[
i
],
fullname
:
cur_names
[
i
],
is_last
:
i
==
(
cur_names
-
1
)
is_last
:
i
==
(
cur_names
.
length
-
1
)
});
});
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.offline
'
).
find
(
'
a.open-chat
'
).
text
();
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.offline
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
expect
(
t
).
toEqual
(
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
sleep
(
timeout
);
}
}
sleep
(
timeout
);
},
xmppchat
));
},
xmppchat
));
it
(
"
shows the current contacts heading if they have been added
"
,
$
.
proxy
(
function
()
{
it
(
"
shows the current contacts heading if they have been added
"
,
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
css
(
'
display
'
)).
toEqual
(
'
block
'
);
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
css
(
'
display
'
)).
toEqual
(
'
block
'
);
},
xmppchat
));
},
xmppchat
));
// 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
it
(
"
hides the requesting contacts heading if there aren't any
"
,
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contact-requests
'
).
is
(
'
:visible
'
)).
toEqual
(
false
);
},
xmppchat
));
it
(
"
can add requesting contacts, and they should be sorted alphabetically
"
,
$
.
proxy
(
function
()
{
var
i
,
t
;
spyOn
(
this
.
rosterview
,
'
render
'
).
andCallThrough
();
spyOn
(
this
,
'
showControlBox
'
).
andCallThrough
();
for
(
i
=
0
;
i
<
req_names
.
length
;
i
++
)
{
this
.
roster
.
create
({
jid
:
req_names
[
i
].
replace
(
'
'
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
none
'
,
ask
:
'
request
'
,
fullname
:
req_names
[
i
],
is_last
:
i
==
(
req_names
.
length
-
1
)
});
expect
(
this
.
rosterview
.
render
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contact-requests
'
).
siblings
(
'
dd.requesting-xmpp-contact
'
).
text
().
replace
(
/AcceptDecline/g
,
''
);
expect
(
t
).
toEqual
(
req_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
// When a requesting contact is added, the controlbox must
// be opened.
expect
(
this
.
showControlBox
).
toHaveBeenCalled
();
}
sleep
(
timeout
);
},
xmppchat
));
it
(
"
shows the requesting contacts heading after they have been added
"
,
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contact-requests
'
).
css
(
'
display
'
)).
toEqual
(
'
block
'
);
},
xmppchat
));
it
(
"
allows the user to accept or decline requesting contacts
"
,
$
.
proxy
(
function
()
{
// TODO
},
xmppchat
));
describe
(
"
Roster items
"
,
$
.
proxy
(
function
()
{
describe
(
"
Roster items
"
,
$
.
proxy
(
function
()
{
it
(
"
are saved to, and can be retrieved from, localStorage
"
,
$
.
proxy
(
function
()
{
it
(
"
are saved to, and can be retrieved from, localStorage
"
,
$
.
proxy
(
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