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
f4c2327e
Commit
f4c2327e
authored
Apr 14, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sleep funtion to slow down tests
Allows one to visually follow whats going on.
parent
7852f67a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
spec/MainSpec.js
spec/MainSpec.js
+21
-2
No files found.
spec/MainSpec.js
View file @
f4c2327e
...
...
@@ -55,10 +55,18 @@
// The timeout is used to slow down the tests so that one can see
// visually what is happening in the page.
this
.
timeout
=
1000
;
var
timeout
=
200
;
var
sleep
=
function
(
delay
)
{
// Yes this is blocking and stupid, but these are tests and this is
// the easiest way to delay execution without having to use
// callbacks.
var
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
<
start
+
delay
)
{
continue
;
}
};
describe
(
"
The contacts roster
"
,
$
.
proxy
(
function
()
{
it
(
"
is not shown by default
"
,
$
.
proxy
(
function
()
{
expect
(
this
.
rosterview
.
$el
.
is
(
'
:visible
'
)).
toEqual
(
false
);
},
xmppchat
));
...
...
@@ -76,6 +84,7 @@
},
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
();
...
...
@@ -94,6 +103,7 @@
// When a requesting contact is added, the controlbox must
// be opened.
expect
(
this
.
showControlBox
).
toHaveBeenCalled
();
sleep
(
timeout
);
}
},
xmppchat
));
...
...
@@ -120,6 +130,7 @@
// Check that they are sorted alphabetically
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
(
''
));
sleep
(
timeout
);
}
},
xmppchat
));
...
...
@@ -146,6 +157,7 @@
// 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
();
expect
(
t
).
toEqual
(
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
sleep
(
timeout
);
}
},
xmppchat
));
...
...
@@ -198,6 +210,7 @@
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.online
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
cur_names
.
slice
(
0
,
i
+
1
).
sort
().
join
(
''
));
sleep
(
timeout
);
}
},
xmppchat
));
...
...
@@ -215,6 +228,7 @@
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.dnd
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
cur_names
.
slice
(
5
,
i
+
1
).
sort
().
join
(
''
));
sleep
(
timeout
);
}
},
xmppchat
));
...
...
@@ -233,6 +247,7 @@
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.away
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
cur_names
.
slice
(
10
,
i
+
1
).
sort
().
join
(
''
));
sleep
(
timeout
);
}
},
xmppchat
));
...
...
@@ -251,6 +266,7 @@
// Check that they are sorted alphabetically
t
=
this
.
rosterview
.
$el
.
find
(
'
dt#xmpp-contacts
'
).
siblings
(
'
dd.current-xmpp-contact.unavailable
'
).
find
(
'
a.open-chat
'
).
text
();
expect
(
t
).
toEqual
(
cur_names
.
slice
(
15
,
i
+
1
).
sort
().
join
(
''
));
sleep
(
timeout
);
}
},
xmppchat
));
...
...
@@ -282,6 +298,7 @@
},
xmppchat
));
describe
(
"
Chatboxes
"
,
$
.
proxy
(
function
()
{
it
(
"
are created when you click on a roster item
"
,
$
.
proxy
(
function
()
{
var
i
,
$el
,
click
,
jid
,
view
;
// showControlBox was called earlier, so the controlbox is
...
...
@@ -298,6 +315,7 @@
$el
.
click
();
expect
(
view
.
openChat
).
toHaveBeenCalled
();
expect
(
this
.
chatboxes
.
length
).
toEqual
(
i
+
2
);
sleep
(
timeout
);
}
},
xmppchat
));
...
...
@@ -330,6 +348,7 @@
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
view
.
$el
.
find
(
'
.close-chatbox-button
'
).
click
();
expect
(
view
.
closeChat
).
toHaveBeenCalled
();
sleep
(
timeout
);
}
},
xmppchat
));
...
...
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