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
702cddd8
Commit
702cddd8
authored
Nov 27, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for account registration.
parent
444734a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
3 deletions
+103
-3
spec/register.js
spec/register.js
+101
-0
tests/main.js
tests/main.js
+2
-3
No files found.
spec/register.js
0 → 100644
View file @
702cddd8
(
function
(
root
,
factory
)
{
define
([
"
jquery
"
,
"
mock
"
,
"
test_utils
"
],
function
(
$
,
mock
,
test_utils
)
{
return
factory
(
$
,
mock
,
test_utils
);
}
);
}
(
this
,
function
(
$
,
mock
,
test_utils
)
{
describe
(
"
The Registration Panel
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
beforeEach
(
function
()
{
test_utils
.
openControlBox
();
});
afterEach
(
function
()
{
test_utils
.
closeControlBox
();
});
it
(
"
is not available unless allow_registration=true
"
,
$
.
proxy
(
function
()
{
test_utils
.
closeControlBox
();
var
connection
=
mock
.
mock_connection
;
connection
.
connected
=
false
;
converse
.
_tearDown
();
converse
.
initialize
({
animate
:
false
,
auto_subscribe
:
false
,
bosh_service_url
:
'
localhost
'
,
connection
:
connection
,
no_trimming
:
true
,
allow_registration
:
false
,
debug
:
true
});
test_utils
.
openControlBox
();
var
cbview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
);
expect
(
cbview
.
$
(
'
#controlbox-tabs li
'
).
length
).
toBe
(
1
);
expect
(
cbview
.
$
(
'
#controlbox-tabs li
'
).
text
().
trim
()).
toBe
(
"
Sign in
"
);
connection
=
mock
.
mock_connection
;
connection
.
connected
=
false
;
converse
.
_tearDown
();
converse
.
initialize
({
bosh_service_url
:
'
localhost
'
,
allow_registration
:
true
,
auto_subscribe
:
false
,
animate
:
false
,
connection
:
connection
,
no_trimming
:
true
,
debug
:
true
});
test_utils
.
openControlBox
();
cbview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
);
expect
(
cbview
.
$el
.
find
(
'
#controlbox-tabs li
'
).
length
).
toBe
(
2
);
expect
(
cbview
.
$
(
'
#controlbox-tabs li
'
).
first
().
text
().
trim
()).
toBe
(
"
Sign in
"
);
expect
(
cbview
.
$
(
'
#controlbox-tabs li
'
).
last
().
text
().
trim
()).
toBe
(
"
Register
"
);
},
converse
));
it
(
"
can be opened by clicking on the registration tab
"
,
$
.
proxy
(
function
()
{
var
cbview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
);
var
$tabs
=
cbview
.
$
(
'
#controlbox-tabs
'
);
var
$panels
=
cbview
.
$
(
'
.controlbox-panes
'
);
var
$login
=
$panels
.
children
().
first
();
var
$registration
=
$panels
.
children
().
last
();
spyOn
(
cbview
,
'
switchTab
'
).
andCallThrough
();
cbview
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
$tabs
.
find
(
'
li
'
).
last
().
find
(
'
a
'
).
click
();
// Click the Register tab
expect
(
$login
.
is
(
'
:visible
'
)).
toBe
(
false
);
expect
(
$registration
.
is
(
'
:visible
'
)).
toBe
(
true
);
expect
(
cbview
.
switchTab
).
toHaveBeenCalled
();
},
converse
));
it
(
"
allows the user to choose an XMPP provider's domain
"
,
$
.
proxy
(
function
()
{
var
cbview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
);
var
registerview
=
cbview
.
registerpanel
;
spyOn
(
registerview
,
'
onProviderChosen
'
).
andCallThrough
();
registerview
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
spyOn
(
this
.
connection
,
'
connect
'
);
var
$tabs
=
cbview
.
$
(
'
#controlbox-tabs
'
);
$tabs
.
find
(
'
li
'
).
last
().
find
(
'
a
'
).
click
();
// Click the Register tab
// Check the form layout
var
$form
=
cbview
.
$
(
'
#converse-register
'
);
expect
(
$form
.
find
(
'
input
'
).
length
).
toEqual
(
2
);
expect
(
$form
.
find
(
'
input
'
).
first
().
attr
(
'
name
'
)).
toEqual
(
'
domain
'
);
expect
(
$form
.
find
(
'
input
'
).
last
().
attr
(
'
type
'
)).
toEqual
(
'
submit
'
);
// Check that the input[type=domain] input is required
$form
.
find
(
'
input[type=submit]
'
).
click
();
expect
(
registerview
.
onProviderChosen
).
toHaveBeenCalled
();
expect
(
$form
.
find
(
'
input[name=domain]
'
).
hasClass
(
'
error
'
)).
toBeTruthy
();
// Check that the form is accepted if input[type=domain] has a value
$form
.
find
(
'
input[name=domain]
'
).
val
(
'
conversejs.org
'
);
$form
.
find
(
'
input[type=submit]
'
).
click
();
expect
(
registerview
.
onProviderChosen
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
connect
).
toHaveBeenCalled
();
},
converse
));
it
(
"
will render a registration form as received from the XMPP provider
"
,
$
.
proxy
(
function
()
{
// TODO
},
converse
));
},
converse
,
mock
,
test_utils
));
}));
tests/main.js
View file @
702cddd8
...
...
@@ -42,8 +42,6 @@ require([
window
.
sessionStorage
.
clear
();
converse
.
initialize
({
prebind
:
false
,
xhr_user_search
:
false
,
auto_subscribe
:
false
,
animate
:
false
,
connection
:
mock
.
mock_connection
,
...
...
@@ -68,7 +66,8 @@ require([
"
spec/chatbox
"
,
"
spec/chatroom
"
,
"
spec/minchats
"
,
"
spec/profiling
"
"
spec/profiling
"
,
"
spec/register
"
],
function
()
{
// Make sure this callback is only called once.
delete
converse
.
callback
;
...
...
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