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
5e4d6bd3
Commit
5e4d6bd3
authored
Oct 24, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial work on adding profiling tests.
parent
7e42783c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
10 deletions
+153
-10
main.js
main.js
+1
-0
spec/controlbox.js
spec/controlbox.js
+47
-0
spec/profiling.js
spec/profiling.js
+58
-0
tests/main.js
tests/main.js
+4
-4
tests/mock.js
tests/mock.js
+32
-6
tests/utils.js
tests/utils.js
+11
-0
No files found.
main.js
View file @
5e4d6bd3
...
...
@@ -139,6 +139,7 @@ config = {
'
crypto.sha1
'
:
{
deps
:
[
'
crypto.core
'
]
},
'
crypto.sha256
'
:
{
deps
:
[
'
crypto.core
'
]
},
'
bigint
'
:
{
deps
:
[
'
crypto
'
]
},
'
strophe
'
:
{
exports
:
'
Strophe
'
},
'
strophe.disco
'
:
{
deps
:
[
'
strophe
'
]
},
'
strophe.muc
'
:
{
deps
:
[
'
strophe
'
]
},
'
strophe.roster
'
:
{
deps
:
[
'
strophe
'
]
},
...
...
spec/controlbox.js
View file @
5e4d6bd3
...
...
@@ -385,6 +385,11 @@
},
converse
));
it
(
"
can be removed by the user
"
,
$
.
proxy
(
function
()
{
// XXX
// This tests fails because "remove" function in strophe.roster
// (line 292) gets called and it then tries to actually remove
// the user which is not in the roster...
// We'll perhaps have to first add the user again...
_addContacts
();
var
name
=
mock
.
pend_names
[
0
];
var
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -764,6 +769,48 @@
// There should now be one less contact
expect
(
this
.
roster
.
length
).
toEqual
(
mock
.
req_names
.
length
-
1
);
},
converse
));
it
(
"
are persisted even if other contacts' change their presence
"
,
$
.
proxy
(
function
()
{
/* This is a regression test.
* https://github.com/jcbrand/converse.js/issues/262
*/
this
.
rosterview
.
model
.
reset
();
spyOn
(
this
.
roster
,
'
clearCache
'
).
andCallThrough
();
expect
(
this
.
roster
.
pluck
(
'
jid
'
).
length
).
toBe
(
0
);
var
stanza
=
$pres
({
from
:
'
data@enterprise/resource
'
,
type
:
'
subscribe
'
});
this
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
this
.
roster
.
pluck
(
'
jid
'
).
length
).
toBe
(
1
);
expect
(
_
.
contains
(
this
.
roster
.
pluck
(
'
jid
'
),
'
data@enterprise
'
)).
toBeTruthy
();
// Taken from the spec
// http://xmpp.org/rfcs/rfc3921.html#rfc.section.7.3
stanza
=
$iq
({
to
:
this
.
connection
.
jid
,
type
:
'
result
'
,
id
:
'
roster_1
'
}).
c
(
'
query
'
,
{
xmlns
:
'
jabber:iq:roster
'
,
}).
c
(
'
item
'
,
{
jid
:
'
romeo@example.net
'
,
name
:
'
Romeo
'
,
subscription
:
'
both
'
}).
c
(
'
group
'
).
t
(
'
Friends
'
).
up
().
up
()
.
c
(
'
item
'
,
{
jid
:
'
mercutio@example.org
'
,
name
:
'
Mercutio
'
,
subscription
:
'
from
'
}).
c
(
'
group
'
).
t
(
'
Friends
'
).
up
().
up
()
.
c
(
'
item
'
,
{
jid
:
'
benvolio@example.org
'
,
name
:
'
Benvolio
'
,
subscription
:
'
both
'
}).
c
(
'
group
'
).
t
(
'
Friends
'
);
this
.
connection
.
roster
.
_onReceiveRosterSuccess
(
null
,
stanza
.
tree
());
expect
(
this
.
roster
.
clearCache
).
toHaveBeenCalled
();
expect
(
_
.
contains
(
this
.
roster
.
pluck
(
'
jid
'
),
'
data@enterprise
'
)).
toBeTruthy
();
},
converse
));
},
converse
));
describe
(
"
All Contacts
"
,
$
.
proxy
(
function
()
{
...
...
spec/profiling.js
0 → 100644
View file @
5e4d6bd3
(
function
(
root
,
factory
)
{
define
([
"
jquery
"
,
"
mock
"
,
"
test_utils
"
],
function
(
$
,
mock
,
test_utils
)
{
return
factory
(
$
,
mock
,
test_utils
);
}
);
}
(
this
,
function
(
$
,
mock
,
test_utils
)
{
describe
(
"
Profiling
"
,
function
()
{
var
roster
;
beforeEach
(
function
()
{
roster
=
converse
.
connection
.
roster
;
converse
.
connection
.
_changeConnectStatus
(
Strophe
.
Status
.
CONNECTED
);
});
it
(
"
adds contacts on presence stanza
"
,
$
.
proxy
(
function
()
{
spyOn
(
this
.
roster
,
'
clearCache
'
).
andCallThrough
();
expect
(
this
.
roster
.
pluck
(
'
jid
'
).
length
).
toBe
(
0
);
var
stanza
=
$pres
({
from
:
'
data@enterprise/resource
'
,
type
:
'
subscribe
'
});
this
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
this
.
roster
.
pluck
(
'
jid
'
).
length
).
toBe
(
1
);
expect
(
_
.
contains
(
this
.
roster
.
pluck
(
'
jid
'
),
'
data@enterprise
'
)).
toBeTruthy
();
// Taken from the spec
// http://xmpp.org/rfcs/rfc3921.html#rfc.section.7.3
stanza
=
$iq
({
to
:
this
.
connection
.
jid
,
type
:
'
result
'
,
id
:
'
roster_1
'
}).
c
(
'
query
'
,
{
xmlns
:
'
jabber:iq:roster
'
,
}).
c
(
'
item
'
,
{
jid
:
'
romeo@example.net
'
,
name
:
'
Romeo
'
,
subscription
:
'
both
'
}).
c
(
'
group
'
).
t
(
'
Friends
'
).
up
().
up
()
.
c
(
'
item
'
,
{
jid
:
'
mercutio@example.org
'
,
name
:
'
Mercutio
'
,
subscription
:
'
from
'
}).
c
(
'
group
'
).
t
(
'
Friends
'
).
up
().
up
()
.
c
(
'
item
'
,
{
jid
:
'
benvolio@example.org
'
,
name
:
'
Benvolio
'
,
subscription
:
'
both
'
}).
c
(
'
group
'
).
t
(
'
Friends
'
);
this
.
connection
.
roster
.
_onReceiveRosterSuccess
(
null
,
stanza
.
tree
());
expect
(
this
.
roster
.
clearCache
).
toHaveBeenCalled
();
expect
(
_
.
contains
(
this
.
roster
.
pluck
(
'
jid
'
),
'
data@enterprise
'
)).
toBeTruthy
();
},
converse
));
});
}));
tests/main.js
View file @
5e4d6bd3
...
...
@@ -40,8 +40,6 @@ require([
window
.
converse_api
=
converse
;
window
.
localStorage
.
clear
();
window
.
sessionStorage
.
clear
();
// XXX: call this to initialize Strophe plugins
new
Strophe
.
Connection
(
'
localhost
'
);
converse
.
initialize
({
prebind
:
false
,
...
...
@@ -49,7 +47,8 @@ require([
auto_subscribe
:
false
,
animate
:
false
,
connection
:
mock
.
mock_connection
,
no_trimming
:
true
no_trimming
:
true
,
debug
:
true
},
function
(
converse
)
{
window
.
converse
=
converse
;
window
.
crypto
=
{
...
...
@@ -68,7 +67,8 @@ require([
"
spec/controlbox
"
,
"
spec/chatbox
"
,
"
spec/chatroom
"
,
"
spec/minchats
"
"
spec/minchats
"
,
"
spec/profiling
"
],
function
()
{
// Make sure this callback is only called once.
delete
converse
.
callback
;
...
...
tests/mock.js
View file @
5e4d6bd3
...
...
@@ -36,11 +36,37 @@
'
preventDefault
'
:
function
()
{}
};
mock
.
mock_connection
=
{
'
_proto
'
:
{},
'
connected
'
:
true
,
'
authenticated
'
:
true
,
'
mock
'
:
true
,
mock
.
mock_connection
=
function
()
{
Strophe
.
Bosh
.
prototype
.
_processRequest
=
function
()
{};
// Don't attempt to send out stanzas
var
c
=
new
Strophe
.
Connection
(
'
jasmine tests
'
);
c
.
authenticated
=
true
;
c
.
connected
=
true
;
c
.
mock
=
true
;
c
.
jid
=
'
dummy@localhost/resource
'
;
c
.
vcard
=
{
'
get
'
:
function
(
callback
,
jid
)
{
var
fullname
;
if
(
!
jid
)
{
jid
=
'
dummy@localhost
'
;
fullname
=
'
Max Mustermann
'
;
}
else
{
var
name
=
jid
.
split
(
'
@
'
)[
0
].
replace
(
/
\.
/g
,
'
'
).
split
(
'
'
);
var
last
=
name
.
length
-
1
;
name
[
0
]
=
name
[
0
].
charAt
(
0
).
toUpperCase
()
+
name
[
0
].
slice
(
1
);
name
[
last
]
=
name
[
last
].
charAt
(
0
).
toUpperCase
()
+
name
[
last
].
slice
(
1
);
fullname
=
name
.
join
(
'
'
);
}
var
vcard
=
$iq
().
c
(
'
vCard
'
).
c
(
'
FN
'
).
t
(
fullname
);
callback
(
vcard
.
tree
());
}
};
c
.
_changeConnectStatus
(
Strophe
.
Status
.
CONNECTED
);
c
.
attach
(
c
.
jid
);
return
c
;
}();
/*
{
'muc': {
'listRooms': function () {},
'join': function () {},
...
...
@@ -49,7 +75,6 @@
'groupchat': function () {return String((new Date()).getTime()); }
},
'service': 'jasmine tests',
'
jid
'
:
'
dummy@localhost
'
,
'addHandler': function (handler, ns, name, type, id, from, options) {
return function () {};
},
...
...
@@ -87,5 +112,6 @@
'items': function () {}
}
};
*/
return
mock
;
}));
tests/utils.js
View file @
5e4d6bd3
...
...
@@ -8,6 +8,17 @@
});
}(
this
,
function
(
$
,
mock
)
{
var
utils
=
{};
utils
.
createRequest
=
function
(
iq
)
{
iq
=
typeof
iq
.
tree
==
"
function
"
?
iq
.
tree
()
:
iq
;
var
req
=
new
Strophe
.
Request
(
iq
,
function
()
{});
req
.
getResponse
=
function
()
{
var
env
=
new
Strophe
.
Builder
(
'
env
'
,
{
type
:
'
mock
'
}).
tree
();
env
.
appendChild
(
iq
);
return
env
;
};
return
req
;
};
utils
.
closeAllChatBoxes
=
function
()
{
var
i
,
chatbox
;
...
...
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