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
176c7243
Commit
176c7243
authored
Dec 19, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split API into public and private (plugin only) parts.
parent
56e6c7ce
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
137 additions
and
391 deletions
+137
-391
docs/CHANGES.md
docs/CHANGES.md
+1
-3
docs/source/developer_api.rst
docs/source/developer_api.rst
+16
-7
spec/bookmarks.js
spec/bookmarks.js
+3
-31
spec/chatbox.js
spec/chatbox.js
+1
-61
spec/chatroom.js
spec/chatroom.js
+17
-37
spec/controlbox.js
spec/controlbox.js
+0
-56
spec/converse.js
spec/converse.js
+40
-46
spec/disco.js
spec/disco.js
+0
-5
spec/headline.js
spec/headline.js
+0
-5
spec/mam.js
spec/mam.js
+10
-22
spec/minchats.js
spec/minchats.js
+0
-6
spec/notification.js
spec/notification.js
+0
-9
spec/otr.js
spec/otr.js
+1
-5
spec/ping.js
spec/ping.js
+1
-9
spec/protocol.js
spec/protocol.js
+27
-33
spec/register.js
spec/register.js
+0
-5
spec/xmppstatus.js
spec/xmppstatus.js
+0
-4
src/converse-api.js
src/converse-api.js
+11
-30
src/converse-bookmarks.js
src/converse-bookmarks.js
+1
-1
src/converse-mam.js
src/converse-mam.js
+1
-1
src/converse-muc.js
src/converse-muc.js
+4
-4
src/converse-ping.js
src/converse-ping.js
+0
-11
tests/mock.js
tests/mock.js
+3
-0
No files found.
docs/CHANGES.md
View file @
176c7243
# Changelog
# Changelog
## 3.0.0 (Unreleased)
## 3.0.0 (Unreleased)
-
Breaking change
: Callbacks for
`converse.on`
now no longer receive an event
-
*Breaking change*
: Callbacks for
`converse.on`
now no longer receive an event
object as first parameter. [jcbrand]
object as first parameter. [jcbrand]
-
Cancel button shown while the registration form is being fetched wasn't working
properly. [jcbrand]
## 2.0.5 (Unreleased)
## 2.0.5 (Unreleased)
-
#743, #751, #753 Update to Strophe 1.2.12. SASL-EXTERNAL now has reduced priority, so it won't
-
#743, #751, #753 Update to Strophe 1.2.12. SASL-EXTERNAL now has reduced priority, so it won't
...
...
docs/source/developer_api.rst
View file @
176c7243
...
@@ -12,17 +12,27 @@ The converse.js developer API
...
@@ -12,17 +12,27 @@ The converse.js developer API
.. note:: The API documented here is available in Converse.js 0.8.4 and higher.
.. note:: The API documented here is available in Converse.js 0.8.4 and higher.
Earlier versions of Converse.js might have different API methods or none at all.
Earlier versions of Converse.js might have different API methods or none at all.
In the Converse.js API, you traverse towards a logical grouping, from
.. note:: From version 3.0.0 and onwards many API methods have been made
which you can then call certain standardised accessors and mutators, such as::
private and available to plugins only. This means that if you want to
use the API, you'll first need to create a plugin from which you can
access it. This change is done to avoid leakage of sensitive data to
malicious or non-whitelisted scripts.
The Converse.js API is broken up into different logical "groupings" (for
example ``converse.plugins`` or ``converse.contacts``).
The one exception, is ``converse.initialize``, which is not a grouping, but a
single method.
The groupings logically group methods, such as standardised accessors and
mutators::
.get
.get
.set
.set
.add
.add
.remove
.remove
This is done to increase readability and to allow intuitive method chaining.
So for example, to get a contact, you would do the following::
For example, to get a contact, you would do the following::
converse.contacts.get('jid@example.com');
converse.contacts.get('jid@example.com');
...
@@ -41,8 +51,7 @@ To get all contacts, simply call ``get`` without any jids::
...
@@ -41,8 +51,7 @@ To get all contacts, simply call ``get`` without any jids::
initialize
initialize
----------
----------
.. note:: This method is the one exception of a method which is not logically grouped
.. note:: This method is the one exception of a method which is not logically grouped as explained above.
as explained above.
Initializes converse.js. This method must always be called when using
Initializes converse.js. This method must always be called when using
converse.js.
converse.js.
...
...
spec/bookmarks.js
View file @
176c7243
...
@@ -14,12 +14,6 @@
...
@@ -14,12 +14,6 @@
describe
(
"
A chat room
"
,
function
()
{
describe
(
"
A chat room
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can be bookmarked
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be bookmarked
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
sent_stanza
,
IQ_id
;
var
sent_stanza
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
...
@@ -151,12 +145,6 @@
...
@@ -151,12 +145,6 @@
describe
(
"
when bookmarked
"
,
function
()
{
describe
(
"
when bookmarked
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
displays that it's bookmarked through its bookmark icon
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
displays that it's bookmarked through its bookmark icon
"
,
mock
.
initConverse
(
function
(
converse
)
{
runs
(
function
()
{
runs
(
function
()
{
test_utils
.
openChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
...
@@ -241,14 +229,9 @@
...
@@ -241,14 +229,9 @@
});
});
describe
(
"
and when autojoin is set
"
,
function
()
{
describe
(
"
and when autojoin is set
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
will be be opened and joined automatically upon login
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
will be be opened and joined automatically upon login
"
,
mock
.
initConverse
(
function
(
converse
)
{
spyOn
(
converse
_
api
.
rooms
,
'
open
'
);
spyOn
(
converse
.
api
.
rooms
,
'
open
'
);
var
jid
=
'
theplay@conference.shakespeare.lit
'
;
var
jid
=
'
theplay@conference.shakespeare.lit
'
;
var
model
=
converse
.
bookmarks
.
create
({
var
model
=
converse
.
bookmarks
.
create
({
'
jid
'
:
jid
,
'
jid
'
:
jid
,
...
@@ -256,7 +239,7 @@
...
@@ -256,7 +239,7 @@
'
name
'
:
'
The Play
'
,
'
name
'
:
'
The Play
'
,
'
nick
'
:
''
'
nick
'
:
''
});
});
expect
(
converse
_
api
.
rooms
.
open
).
not
.
toHaveBeenCalled
();
expect
(
converse
.
api
.
rooms
.
open
).
not
.
toHaveBeenCalled
();
converse
.
bookmarks
.
remove
(
model
);
converse
.
bookmarks
.
remove
(
model
);
converse
.
bookmarks
.
create
({
converse
.
bookmarks
.
create
({
...
@@ -265,19 +248,13 @@
...
@@ -265,19 +248,13 @@
'
name
'
:
'
Hamlet
'
,
'
name
'
:
'
Hamlet
'
,
'
nick
'
:
''
'
nick
'
:
''
});
});
expect
(
converse
_
api
.
rooms
.
open
).
toHaveBeenCalled
();
expect
(
converse
.
api
.
rooms
.
open
).
toHaveBeenCalled
();
}));
}));
});
});
});
});
describe
(
"
Bookmarks
"
,
function
()
{
describe
(
"
Bookmarks
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can be pushed from the XMPP server
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be pushed from the XMPP server
"
,
mock
.
initConverse
(
function
(
converse
)
{
// TODO
// TODO
/* The stored data is automatically pushed to all of the user's
/* The stored data is automatically pushed to all of the user's
...
@@ -395,11 +372,6 @@
...
@@ -395,11 +372,6 @@
}));
}));
describe
(
"
The rooms panel
"
,
function
()
{
describe
(
"
The rooms panel
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
shows a list of bookmarks
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
shows a list of bookmarks
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
IQ_id
;
var
IQ_id
;
...
...
spec/chatbox.js
View file @
176c7243
...
@@ -15,11 +15,6 @@
...
@@ -15,11 +15,6 @@
return
describe
(
"
Chatboxes
"
,
function
()
{
return
describe
(
"
Chatboxes
"
,
function
()
{
describe
(
"
A Chatbox
"
,
function
()
{
describe
(
"
A Chatbox
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is created when you click on a roster item
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is created when you click on a roster item
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -277,11 +272,6 @@
...
@@ -277,11 +272,6 @@
}));
}));
describe
(
"
A chat toolbar
"
,
function
()
{
describe
(
"
A chat toolbar
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can be found on each chat box
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be found on each chat box
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -452,11 +442,6 @@
...
@@ -452,11 +442,6 @@
});
});
describe
(
"
A Chat Message
"
,
function
()
{
describe
(
"
A Chat Message
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
describe
(
"
when received from someone else
"
,
function
()
{
describe
(
"
when received from someone else
"
,
function
()
{
it
(
"
can be received which will open a chatbox and be displayed inside it
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be received which will open a chatbox and be displayed inside it
"
,
mock
.
initConverse
(
function
(
converse
)
{
...
@@ -507,11 +492,6 @@
...
@@ -507,11 +492,6 @@
}));
}));
describe
(
"
and for which then an error message is received from the server
"
,
function
()
{
describe
(
"
and for which then an error message is received from the server
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
will have the error message displayed after itself
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
will have the error message displayed after itself
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -536,7 +516,7 @@
...
@@ -536,7 +516,7 @@
var
sender_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
sender_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
fullname
=
converse
.
xmppstatus
.
get
(
'
fullname
'
);
var
fullname
=
converse
.
xmppstatus
.
get
(
'
fullname
'
);
fullname
=
_
.
isEmpty
(
fullname
)?
converse
.
bare_jid
:
fullname
;
fullname
=
_
.
isEmpty
(
fullname
)?
converse
.
bare_jid
:
fullname
;
converse
_
api
.
chats
.
open
(
sender_jid
);
converse
.
api
.
chats
.
open
(
sender_jid
);
var
msg_text
=
'
This message will not be sent, due to an error
'
;
var
msg_text
=
'
This message will not be sent, due to an error
'
;
var
view
=
converse
.
chatboxviews
.
get
(
sender_jid
);
var
view
=
converse
.
chatboxviews
.
get
(
sender_jid
);
var
message
=
view
.
model
.
messages
.
create
({
var
message
=
view
.
model
.
messages
.
create
({
...
@@ -1143,11 +1123,6 @@
...
@@ -1143,11 +1123,6 @@
});
});
describe
(
"
A Chat Status Notification
"
,
function
()
{
describe
(
"
A Chat Status Notification
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
does not open automatically if a chat state notification is received
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
does not open automatically if a chat state notification is received
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -1168,11 +1143,6 @@
...
@@ -1168,11 +1143,6 @@
}));
}));
describe
(
"
An active notification
"
,
function
()
{
describe
(
"
An active notification
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is sent when the user opens a chat box
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is sent when the user opens a chat box
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -1225,11 +1195,6 @@
...
@@ -1225,11 +1195,6 @@
});
});
describe
(
"
A composing notification
"
,
function
()
{
describe
(
"
A composing notification
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is sent as soon as the user starts typing a message which is not a command
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is sent as soon as the user starts typing a message which is not a command
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -1292,11 +1257,6 @@
...
@@ -1292,11 +1257,6 @@
});
});
describe
(
"
A paused notification
"
,
function
()
{
describe
(
"
A paused notification
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is sent if the user has stopped typing since 30 seconds
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is sent if the user has stopped typing since 30 seconds
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -1381,11 +1341,6 @@
...
@@ -1381,11 +1341,6 @@
});
});
describe
(
"
An inactive notifciation
"
,
function
()
{
describe
(
"
An inactive notifciation
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is sent if the user has stopped typing since 2 minutes
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is sent if the user has stopped typing since 2 minutes
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -1493,11 +1448,6 @@
...
@@ -1493,11 +1448,6 @@
});
});
describe
(
"
A gone notifciation
"
,
function
()
{
describe
(
"
A gone notifciation
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
will be shown if received
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
will be shown if received
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -1524,11 +1474,6 @@
...
@@ -1524,11 +1474,6 @@
});
});
describe
(
"
Special Messages
"
,
function
()
{
describe
(
"
Special Messages
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
'/clear' can be used to clear messages in a conversation
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
'/clear' can be used to clear messages in a conversation
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -1565,11 +1510,6 @@
...
@@ -1565,11 +1510,6 @@
});
});
describe
(
"
A Message Counter
"
,
function
()
{
describe
(
"
A Message Counter
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is incremented when the message is received and the window is not focused
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is incremented when the message is received and the window is not focused
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
...
spec/chatroom.js
View file @
176c7243
...
@@ -10,11 +10,6 @@
...
@@ -10,11 +10,6 @@
return
describe
(
"
ChatRooms
"
,
function
()
{
return
describe
(
"
ChatRooms
"
,
function
()
{
describe
(
"
The
\"
rooms
\"
API
"
,
function
()
{
describe
(
"
The
\"
rooms
\"
API
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
has a method 'close' which closes rooms by JID or all rooms when called with no arguments
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
has a method 'close' which closes rooms by JID or all rooms when called with no arguments
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
@@ -28,11 +23,11 @@
...
@@ -28,11 +23,11 @@
});
});
waits
(
'
100
'
);
waits
(
'
100
'
);
runs
(
function
()
{
runs
(
function
()
{
converse
_
api
.
rooms
.
close
(
'
lounge@localhost
'
);
converse
.
api
.
rooms
.
close
(
'
lounge@localhost
'
);
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
converse
.
chatboxviews
.
get
(
'
news@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
converse
.
chatboxviews
.
get
(
'
news@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
converse
_
api
.
rooms
.
close
([
'
leisure@localhost
'
,
'
news@localhost
'
]);
converse
.
api
.
rooms
.
close
([
'
leisure@localhost
'
,
'
news@localhost
'
]);
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
news@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
news@localhost
'
)).
toBeUndefined
();
...
@@ -44,7 +39,7 @@
...
@@ -44,7 +39,7 @@
});
});
waits
(
'
100
'
);
waits
(
'
100
'
);
runs
(
function
()
{
runs
(
function
()
{
converse
_
api
.
rooms
.
close
();
converse
.
api
.
rooms
.
close
();
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
)).
toBeUndefined
();
});
});
...
@@ -56,7 +51,7 @@
...
@@ -56,7 +51,7 @@
runs
(
function
()
{
runs
(
function
()
{
test_utils
.
openChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
jid
=
'
lounge@localhost
'
;
var
jid
=
'
lounge@localhost
'
;
var
room
=
converse
_
api
.
rooms
.
get
(
jid
);
var
room
=
converse
.
api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
...
@@ -68,7 +63,7 @@
...
@@ -68,7 +63,7 @@
// Test with mixed case
// Test with mixed case
test_utils
.
openChatRoom
(
converse
,
'
Leisure
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
converse
,
'
Leisure
'
,
'
localhost
'
,
'
dummy
'
);
var
jid
=
'
Leisure@localhost
'
;
var
jid
=
'
Leisure@localhost
'
;
var
room
=
converse
_
api
.
rooms
.
get
(
jid
);
var
room
=
converse
.
api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
...
@@ -76,13 +71,13 @@
...
@@ -76,13 +71,13 @@
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
runs
(
function
()
{
var
jid
=
'
leisure@localhost
'
;
var
jid
=
'
leisure@localhost
'
;
var
room
=
converse
_
api
.
rooms
.
get
(
jid
);
var
room
=
converse
.
api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leiSure@localhost
'
;
jid
=
'
leiSure@localhost
'
;
room
=
converse
_
api
.
rooms
.
get
(
jid
);
room
=
converse
.
api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
...
@@ -90,7 +85,7 @@
...
@@ -90,7 +85,7 @@
// Non-existing room
// Non-existing room
jid
=
'
lounge2@localhost
'
;
jid
=
'
lounge2@localhost
'
;
room
=
converse
_
api
.
rooms
.
get
(
jid
);
room
=
converse
.
api
.
rooms
.
get
(
jid
);
expect
(
typeof
room
===
'
undefined
'
).
toBeTruthy
();
expect
(
typeof
room
===
'
undefined
'
).
toBeTruthy
();
});
});
}));
}));
...
@@ -99,7 +94,7 @@
...
@@ -99,7 +94,7 @@
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
var
chatroomview
;
var
chatroomview
;
var
jid
=
'
lounge@localhost
'
;
var
jid
=
'
lounge@localhost
'
;
var
room
=
converse
_
api
.
rooms
.
open
(
jid
);
var
room
=
converse
.
api
.
rooms
.
open
(
jid
);
runs
(
function
()
{
runs
(
function
()
{
// Test on chat room that doesn't exist.
// Test on chat room that doesn't exist.
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
...
@@ -110,7 +105,7 @@
...
@@ -110,7 +105,7 @@
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
runs
(
function
()
{
// Test again, now that the room exists.
// Test again, now that the room exists.
room
=
converse
_
api
.
rooms
.
open
(
jid
);
room
=
converse
.
api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
...
@@ -120,19 +115,19 @@
...
@@ -120,19 +115,19 @@
runs
(
function
()
{
runs
(
function
()
{
// Test with mixed case in JID
// Test with mixed case in JID
jid
=
'
Leisure@localhost
'
;
jid
=
'
Leisure@localhost
'
;
room
=
converse
_
api
.
rooms
.
open
(
jid
);
room
=
converse
.
api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leisure@localhost
'
;
jid
=
'
leisure@localhost
'
;
room
=
converse
_
api
.
rooms
.
open
(
jid
);
room
=
converse
.
api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leiSure@localhost
'
;
jid
=
'
leiSure@localhost
'
;
room
=
converse
_
api
.
rooms
.
open
(
jid
);
room
=
converse
.
api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
...
@@ -148,7 +143,7 @@
...
@@ -148,7 +143,7 @@
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
});
// Test with configuration
// Test with configuration
converse
_
api
.
rooms
.
open
(
'
room@conference.example.org
'
,
{
converse
.
api
.
rooms
.
open
(
'
room@conference.example.org
'
,
{
'
nick
'
:
'
some1
'
,
'
nick
'
:
'
some1
'
,
'
auto_configure
'
:
true
,
'
auto_configure
'
:
true
,
'
roomconfig
'
:
{
'
roomconfig
'
:
{
...
@@ -241,11 +236,6 @@
...
@@ -241,11 +236,6 @@
});
});
describe
(
"
A Chat Room
"
,
function
()
{
describe
(
"
A Chat Room
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can have spaces and special characters in its name
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can have spaces and special characters in its name
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
openChatRoom
(
converse
,
'
lounge & leisure
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
converse
,
'
lounge & leisure
'
,
'
localhost
'
,
'
dummy
'
);
...
@@ -263,7 +253,7 @@
...
@@ -263,7 +253,7 @@
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
});
runs
(
function
()
{
runs
(
function
()
{
converse
_
api
.
rooms
.
open
(
'
coven@chat.shakespeare.lit
'
,
{
'
nick
'
:
'
some1
'
});
converse
.
api
.
rooms
.
open
(
'
coven@chat.shakespeare.lit
'
,
{
'
nick
'
:
'
some1
'
});
view
=
converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
view
=
converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
spyOn
(
view
,
'
saveAffiliationAndRole
'
).
andCallThrough
();
spyOn
(
view
,
'
saveAffiliationAndRole
'
).
andCallThrough
();
...
@@ -915,7 +905,7 @@
...
@@ -915,7 +905,7 @@
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
});
converse
_
api
.
rooms
.
open
(
'
coven@chat.shakespeare.lit
'
,
{
'
nick
'
:
'
some1
'
});
converse
.
api
.
rooms
.
open
(
'
coven@chat.shakespeare.lit
'
,
{
'
nick
'
:
'
some1
'
});
// Check that the room queried for the feautures.
// Check that the room queried for the feautures.
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
...
@@ -980,7 +970,7 @@
...
@@ -980,7 +970,7 @@
sent_IQ
=
iq
;
sent_IQ
=
iq
;
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
});
converse
_
api
.
rooms
.
open
(
'
coven@chat.shakespeare.lit
'
,
{
'
nick
'
:
'
some1
'
});
converse
.
api
.
rooms
.
open
(
'
coven@chat.shakespeare.lit
'
,
{
'
nick
'
:
'
some1
'
});
// We pretend this is a new room, so no disco info is returned.
// We pretend this is a new room, so no disco info is returned.
var
features_stanza
=
$iq
({
var
features_stanza
=
$iq
({
...
@@ -1145,11 +1135,6 @@
...
@@ -1145,11 +1135,6 @@
describe
(
"
Each chat room can take special commands
"
,
function
()
{
describe
(
"
Each chat room can take special commands
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
to clear messages
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
to clear messages
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
openChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
...
@@ -1248,11 +1233,6 @@
...
@@ -1248,11 +1233,6 @@
});
});
describe
(
"
When attempting to enter a chatroom
"
,
function
()
{
describe
(
"
When attempting to enter a chatroom
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
var
submitRoomForm
=
function
(
converse
)
{
var
submitRoomForm
=
function
(
converse
)
{
var
roomspanel
=
converse
.
chatboxviews
.
get
(
'
controlbox
'
).
roomspanel
;
var
roomspanel
=
converse
.
chatboxviews
.
get
(
'
controlbox
'
).
roomspanel
;
...
...
spec/controlbox.js
View file @
176c7243
...
@@ -23,11 +23,6 @@
...
@@ -23,11 +23,6 @@
};
};
describe
(
"
The Control Box
"
,
function
()
{
describe
(
"
The Control Box
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can be opened by clicking a DOM element with class 'toggle-controlbox'
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be opened by clicking a DOM element with class 'toggle-controlbox'
"
,
mock
.
initConverse
(
function
(
converse
)
{
runs
(
function
()
{
runs
(
function
()
{
...
@@ -51,11 +46,6 @@
...
@@ -51,11 +46,6 @@
}));
}));
describe
(
"
The Status Widget
"
,
function
()
{
describe
(
"
The Status Widget
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
shows the user's chat status, which is online by default
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
shows the user's chat status, which is online by default
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
...
@@ -123,11 +113,6 @@
...
@@ -123,11 +113,6 @@
describe
(
"
The Contacts Roster
"
,
function
()
{
describe
(
"
The Contacts Roster
"
,
function
()
{
describe
(
"
The live filter
"
,
function
()
{
describe
(
"
The live filter
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
will only appear when roster contacts flow over the visible area
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
will only appear when roster contacts flow over the visible area
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
$filter
=
converse
.
rosterview
.
$
(
'
.roster-filter
'
);
var
$filter
=
converse
.
rosterview
.
$
(
'
.roster-filter
'
);
...
@@ -332,11 +317,6 @@
...
@@ -332,11 +317,6 @@
});
});
describe
(
"
A Roster Group
"
,
function
()
{
describe
(
"
A Roster Group
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can be used to organize existing contacts
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be used to organize existing contacts
"
,
mock
.
initConverse
(
function
(
converse
)
{
runs
(
function
()
{
runs
(
function
()
{
...
@@ -432,11 +412,6 @@
...
@@ -432,11 +412,6 @@
});
});
describe
(
"
Pending Contacts
"
,
function
()
{
describe
(
"
Pending Contacts
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
function
_addContacts
(
converse
)
{
function
_addContacts
(
converse
)
{
// Must be initialized, so that render is called and documentFragment set up.
// Must be initialized, so that render is called and documentFragment set up.
...
@@ -600,12 +575,6 @@
...
@@ -600,12 +575,6 @@
test_utils
.
createContacts
(
converse
,
'
current
'
).
openControlBox
().
openContactsPanel
(
converse
);
test_utils
.
createContacts
(
converse
,
'
current
'
).
openControlBox
().
openContactsPanel
(
converse
);
};
};
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can be collapsed under their own header
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be collapsed under their own header
"
,
mock
.
initConverse
(
function
(
converse
)
{
runs
(
function
()
{
runs
(
function
()
{
_addContacts
(
converse
);
_addContacts
(
converse
);
...
@@ -897,11 +866,6 @@
...
@@ -897,11 +866,6 @@
});
});
describe
(
"
Requesting Contacts
"
,
function
()
{
describe
(
"
Requesting Contacts
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be added to the roster and they will be sorted alphabetically
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
i
,
children
;
var
i
,
children
;
...
@@ -1062,11 +1026,6 @@
...
@@ -1062,11 +1026,6 @@
});
});
describe
(
"
All Contacts
"
,
function
()
{
describe
(
"
All Contacts
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
are saved to, and can be retrieved from browserStorage
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
are saved to, and can be retrieved from browserStorage
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
all
'
).
openControlBox
();
test_utils
.
createContacts
(
converse
,
'
all
'
).
openControlBox
();
...
@@ -1117,11 +1076,6 @@
...
@@ -1117,11 +1076,6 @@
});
});
describe
(
"
The 'Add Contact' widget
"
,
function
()
{
describe
(
"
The 'Add Contact' widget
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
opens up an add form when you click on it
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
opens up an add form when you click on it
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
panel
=
converse
.
chatboxviews
.
get
(
'
controlbox
'
).
contactspanel
;
var
panel
=
converse
.
chatboxviews
.
get
(
'
controlbox
'
).
contactspanel
;
...
@@ -1135,11 +1089,6 @@
...
@@ -1135,11 +1089,6 @@
});
});
describe
(
"
The Controlbox Tabs
"
,
function
()
{
describe
(
"
The Controlbox Tabs
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
contains two tabs, 'Contacts' and 'ChatRooms'
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
contains two tabs, 'Contacts' and 'ChatRooms'
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
...
@@ -1164,11 +1113,6 @@
...
@@ -1164,11 +1113,6 @@
}));
}));
describe
(
"
chatrooms panel
"
,
function
()
{
describe
(
"
chatrooms panel
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is opened by clicking the 'Chatrooms' tab
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is opened by clicking the 'Chatrooms' tab
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
...
...
spec/converse.js
View file @
176c7243
This diff is collapsed.
Click to expand it.
spec/disco.js
View file @
176c7243
...
@@ -11,11 +11,6 @@
...
@@ -11,11 +11,6 @@
describe
(
"
Service Discovery
"
,
function
()
{
describe
(
"
Service Discovery
"
,
function
()
{
describe
(
"
Whenever converse.js discovers a new server feature
"
,
function
()
{
describe
(
"
Whenever converse.js discovers a new server feature
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
emits the serviceDiscovered event
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
emits the serviceDiscovered event
"
,
mock
.
initConverse
(
function
(
converse
)
{
spyOn
(
converse
,
'
emit
'
);
spyOn
(
converse
,
'
emit
'
);
...
...
spec/headline.js
View file @
176c7243
...
@@ -13,11 +13,6 @@
...
@@ -13,11 +13,6 @@
describe
(
"
A headlines box
"
,
function
()
{
describe
(
"
A headlines box
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
will not open nor display non-headline messages
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
will not open nor display non-headline messages
"
,
mock
.
initConverse
(
function
(
converse
)
{
/* XMPP spam message:
/* XMPP spam message:
*
*
...
...
spec/mam.js
View file @
176c7243
...
@@ -15,12 +15,6 @@
...
@@ -15,12 +15,6 @@
describe
(
"
The archive.query API
"
,
function
()
{
describe
(
"
The archive.query API
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can be used to query for all archived messages
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can be used to query for all archived messages
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
sent_stanza
,
IQ_id
;
var
sent_stanza
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
...
@@ -31,7 +25,7 @@
...
@@ -31,7 +25,7 @@
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
}
}
converse
_
api
.
archive
.
query
();
converse
.
api
.
archive
.
query
();
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
expect
(
sent_stanza
.
toString
()).
toBe
(
expect
(
sent_stanza
.
toString
()).
toBe
(
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'><query xmlns='urn:xmpp:mam:0' queryid='
"
+
queryid
+
"
'/></iq>
"
);
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'><query xmlns='urn:xmpp:mam:0' queryid='
"
+
queryid
+
"
'/></iq>
"
);
...
@@ -47,7 +41,7 @@
...
@@ -47,7 +41,7 @@
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
}
}
converse
_
api
.
archive
.
query
({
'
with
'
:
'
juliet@capulet.lit
'
});
converse
.
api
.
archive
.
query
({
'
with
'
:
'
juliet@capulet.lit
'
});
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
expect
(
sent_stanza
.
toString
()).
toBe
(
expect
(
sent_stanza
.
toString
()).
toBe
(
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
...
@@ -77,7 +71,7 @@
...
@@ -77,7 +71,7 @@
}
}
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
end
=
'
2010-07-07T13:23:54Z
'
;
var
end
=
'
2010-07-07T13:23:54Z
'
;
converse
_
api
.
archive
.
query
({
converse
.
api
.
archive
.
query
({
'
start
'
:
start
,
'
start
'
:
start
,
'
end
'
:
end
'
end
'
:
end
...
@@ -106,7 +100,7 @@
...
@@ -106,7 +100,7 @@
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
}
}
expect
(
_
.
partial
(
converse
_
api
.
archive
.
query
,
{
'
start
'
:
'
not a real date
'
})).
toThrow
(
expect
(
_
.
partial
(
converse
.
api
.
archive
.
query
,
{
'
start
'
:
'
not a real date
'
})).
toThrow
(
new
TypeError
(
'
archive.query: invalid date provided for: start
'
)
new
TypeError
(
'
archive.query: invalid date provided for: start
'
)
);
);
}));
}));
...
@@ -122,7 +116,7 @@
...
@@ -122,7 +116,7 @@
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
}
}
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
start
=
'
2010-06-07T00:00:00Z
'
;
converse
_
api
.
archive
.
query
({
'
start
'
:
start
});
converse
.
api
.
archive
.
query
({
'
start
'
:
start
});
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
expect
(
sent_stanza
.
toString
()).
toBe
(
expect
(
sent_stanza
.
toString
()).
toBe
(
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
...
@@ -151,7 +145,7 @@
...
@@ -151,7 +145,7 @@
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
}
}
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
start
=
'
2010-06-07T00:00:00Z
'
;
converse
_
api
.
archive
.
query
({
'
start
'
:
start
,
'
max
'
:
10
});
converse
.
api
.
archive
.
query
({
'
start
'
:
start
,
'
max
'
:
10
});
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
expect
(
sent_stanza
.
toString
()).
toBe
(
expect
(
sent_stanza
.
toString
()).
toBe
(
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
...
@@ -183,7 +177,7 @@
...
@@ -183,7 +177,7 @@
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
}
}
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
start
=
'
2010-06-07T00:00:00Z
'
;
converse
_
api
.
archive
.
query
({
converse
.
api
.
archive
.
query
({
'
start
'
:
start
,
'
start
'
:
start
,
'
after
'
:
'
09af3-cc343-b409f
'
,
'
after
'
:
'
09af3-cc343-b409f
'
,
'
max
'
:
10
'
max
'
:
10
...
@@ -219,7 +213,7 @@
...
@@ -219,7 +213,7 @@
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
converse
.
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
}
}
converse
_
api
.
archive
.
query
({
'
before
'
:
''
,
'
max
'
:
10
});
converse
.
api
.
archive
.
query
({
'
before
'
:
''
,
'
max
'
:
10
});
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
expect
(
sent_stanza
.
toString
()).
toBe
(
expect
(
sent_stanza
.
toString
()).
toBe
(
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
"
<iq type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
...
@@ -255,7 +249,7 @@
...
@@ -255,7 +249,7 @@
var
rsm
=
new
Strophe
.
RSM
({
'
max
'
:
'
10
'
});
var
rsm
=
new
Strophe
.
RSM
({
'
max
'
:
'
10
'
});
rsm
[
'
with
'
]
=
'
romeo@montague.lit
'
;
rsm
[
'
with
'
]
=
'
romeo@montague.lit
'
;
rsm
.
start
=
'
2010-06-07T00:00:00Z
'
;
rsm
.
start
=
'
2010-06-07T00:00:00Z
'
;
converse
_
api
.
archive
.
query
(
rsm
);
converse
.
api
.
archive
.
query
(
rsm
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
expect
(
sent_stanza
.
toString
()).
toBe
(
expect
(
sent_stanza
.
toString
()).
toBe
(
...
@@ -292,7 +286,7 @@
...
@@ -292,7 +286,7 @@
});
});
var
callback
=
jasmine
.
createSpy
(
'
callback
'
);
var
callback
=
jasmine
.
createSpy
(
'
callback
'
);
converse
_
api
.
archive
.
query
({
'
with
'
:
'
romeo@capulet.lit
'
,
'
max
'
:
'
10
'
},
callback
);
converse
.
api
.
archive
.
query
({
'
with
'
:
'
romeo@capulet.lit
'
,
'
max
'
:
'
10
'
},
callback
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
// Send the result stanza, so that the callback is called.
// Send the result stanza, so that the callback is called.
...
@@ -373,12 +367,6 @@
...
@@ -373,12 +367,6 @@
describe
(
"
The default preference
"
,
function
()
{
describe
(
"
The default preference
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is set once server support for MAM has been confirmed
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is set once server support for MAM has been confirmed
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
sent_stanza
,
IQ_id
;
var
sent_stanza
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
...
...
spec/minchats.js
View file @
176c7243
...
@@ -5,12 +5,6 @@
...
@@ -5,12 +5,6 @@
var
$msg
=
converse_api
.
env
.
$msg
;
var
$msg
=
converse_api
.
env
.
$msg
;
describe
(
"
The Minimized Chats Widget
"
,
function
()
{
describe
(
"
The Minimized Chats Widget
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
shows chats that have been minimized
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
shows chats that have been minimized
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
...
...
spec/notification.js
View file @
176c7243
...
@@ -10,10 +10,6 @@
...
@@ -10,10 +10,6 @@
describe
(
"
When show_desktop_notifications is set to true
"
,
function
()
{
describe
(
"
When show_desktop_notifications is set to true
"
,
function
()
{
describe
(
"
And the desktop is not focused
"
,
function
()
{
describe
(
"
And the desktop is not focused
"
,
function
()
{
describe
(
"
an HTML5 Notification
"
,
function
()
{
describe
(
"
an HTML5 Notification
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is shown when a new private message is received
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is shown when a new private message is received
"
,
mock
.
initConverse
(
function
(
converse
)
{
// TODO: not yet testing show_desktop_notifications setting
// TODO: not yet testing show_desktop_notifications setting
...
@@ -95,11 +91,6 @@
...
@@ -95,11 +91,6 @@
describe
(
"
When play_sounds is set to true
"
,
function
()
{
describe
(
"
When play_sounds is set to true
"
,
function
()
{
describe
(
"
A notification sound
"
,
function
()
{
describe
(
"
A notification sound
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is played when the current user is mentioned in a chat room
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is played when the current user is mentioned in a chat room
"
,
mock
.
initConverse
(
function
(
converse
)
{
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
createContacts
(
converse
,
'
current
'
);
test_utils
.
openAndEnterChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openAndEnterChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
...
...
spec/otr.js
View file @
176c7243
...
@@ -6,10 +6,6 @@
...
@@ -6,10 +6,6 @@
var
b64_sha1
=
converse_api
.
env
.
b64_sha1
;
var
b64_sha1
=
converse_api
.
env
.
b64_sha1
;
return
describe
(
"
The OTR module
"
,
function
()
{
return
describe
(
"
The OTR module
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
can store a session passphrase in session storage
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
can store a session passphrase in session storage
"
,
mock
.
initConverse
(
function
(
converse
)
{
// With no prebind, the user's XMPP password is used and nothing is
// With no prebind, the user's XMPP password is used and nothing is
...
@@ -65,7 +61,7 @@
...
@@ -65,7 +61,7 @@
var
msgtext
=
"
?OTR,1,3,?OTR:AAIDAAAAAAEAAAABAAAAwCQ8HKsag0y0DGKsneo0kzKu1ua5L93M4UKTkCf1I2kbm2RgS5kIxDTxrTj3wVRB+H5Si86E1fKtuBgsDf/bKkGTM0h/49vh5lOD9HkE8cnSrFEn5GN,
"
;
var
msgtext
=
"
?OTR,1,3,?OTR:AAIDAAAAAAEAAAABAAAAwCQ8HKsag0y0DGKsneo0kzKu1ua5L93M4UKTkCf1I2kbm2RgS5kIxDTxrTj3wVRB+H5Si86E1fKtuBgsDf/bKkGTM0h/49vh5lOD9HkE8cnSrFEn5GN,
"
;
var
sender_jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
sender_jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
converse
_
api
.
chats
.
open
(
sender_jid
);
converse
.
api
.
chats
.
open
(
sender_jid
);
var
chatbox
=
converse
.
chatboxes
.
get
(
sender_jid
);
var
chatbox
=
converse
.
chatboxes
.
get
(
sender_jid
);
spyOn
(
converse
.
connection
,
'
send
'
);
spyOn
(
converse
.
connection
,
'
send
'
);
chatbox
.
set
(
'
otr_status
'
,
1
);
// Set OTR status to UNVERIFIED, to mock an encrypted session
chatbox
.
set
(
'
otr_status
'
,
1
);
// Set OTR status to UNVERIFIED, to mock an encrypted session
...
...
spec/ping.js
View file @
176c7243
(
function
(
root
,
factory
)
{
(
function
(
root
,
factory
)
{
define
([
"
mock
"
,
"
converse-api
"
,
"
test_utils
"
,
"
converse-ping
"
],
factory
);
define
([
"
mock
"
,
"
converse-api
"
,
"
test_utils
"
,
"
converse-ping
"
],
factory
);
}
(
this
,
function
(
mock
,
converse_api
,
test_utils
)
{
}
(
this
,
function
(
mock
,
test_utils
)
{
"
use strict
"
;
"
use strict
"
;
describe
(
"
XMPP Ping
"
,
function
()
{
describe
(
"
XMPP Ping
"
,
function
()
{
describe
(
"
Ping and pong handlers
"
,
function
()
{
describe
(
"
Ping and pong handlers
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
are registered when converse.js is connected
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
are registered when converse.js is connected
"
,
mock
.
initConverse
(
function
(
converse
)
{
spyOn
(
converse
,
'
registerPingHandler
'
).
andCallThrough
();
spyOn
(
converse
,
'
registerPingHandler
'
).
andCallThrough
();
...
@@ -28,10 +24,6 @@
...
@@ -28,10 +24,6 @@
});
});
describe
(
"
An IQ stanza
"
,
function
()
{
describe
(
"
An IQ stanza
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is sent out when converse.js pings a server
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is sent out when converse.js pings a server
"
,
mock
.
initConverse
(
function
(
converse
)
{
var
sent_stanza
,
IQ_id
;
var
sent_stanza
,
IQ_id
;
...
...
spec/protocol.js
View file @
176c7243
...
@@ -18,40 +18,34 @@
...
@@ -18,40 +18,34 @@
// Stub the trimChat method. It causes havoc when running with
// Stub the trimChat method. It causes havoc when running with
// phantomJS.
// phantomJS.
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
/* Some level of integration between roster items and presence
/* Some level of integration between roster items and presence
* subscriptions is normally expected by an instant messaging user
* subscriptions is normally expected by an instant messaging user
* regarding the user's subscriptions to and from other contacts. This
* regarding the user's subscriptions to and from other contacts. This
* section describes the level of integration that MUST be supported
* section describes the level of integration that MUST be supported
* within an XMPP instant messaging applications.
* within an XMPP instant messaging applications.
*
*
* There are four primary subscription states:
* There are four primary subscription states:
*
*
* None -- the user does not have a subscription to the contact's
* None -- the user does not have a subscription to the contact's
* presence information, and the contact does not have a subscription
* presence information, and the contact does not have a subscription
* to the user's presence information
* to the user's presence information
* To -- the user has a subscription to the contact's presence
* To -- the user has a subscription to the contact's presence
* information, but the contact does not have a subscription to the
* information, but the contact does not have a subscription to the
* user's presence information
* user's presence information
* From -- the contact has a subscription to the user's presence
* From -- the contact has a subscription to the user's presence
* information, but the user does not have a subscription to the
* information, but the user does not have a subscription to the
* contact's presence information
* contact's presence information
* Both -- both the user and the contact have subscriptions to each
* Both -- both the user and the contact have subscriptions to each
* other's presence information (i.e., the union of 'from' and 'to')
* other's presence information (i.e., the union of 'from' and 'to')
*
*
* Each of these states is reflected in the roster of both the user and
* Each of these states is reflected in the roster of both the user and
* the contact, thus resulting in durable subscription states.
* the contact, thus resulting in durable subscription states.
*
*
* The 'from' and 'to' addresses are OPTIONAL in roster pushes; if
* The 'from' and 'to' addresses are OPTIONAL in roster pushes; if
* included, their values SHOULD be the full JID of the resource for
* included, their values SHOULD be the full JID of the resource for
* that session. A client MUST acknowledge each roster push with an IQ
* that session. A client MUST acknowledge each roster push with an IQ
* stanza of type "result".
* stanza of type "result".
*/
*/
it
(
"
Subscribe to contact, contact accepts and subscribes back
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
Subscribe to contact, contact accepts and subscribes back
"
,
mock
.
initConverse
(
function
(
converse
)
{
/* The process by which a user subscribes to a contact, including
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
* the interaction between roster items and subscription states.
...
...
spec/register.js
View file @
176c7243
...
@@ -6,11 +6,6 @@
...
@@ -6,11 +6,6 @@
var
$iq
=
converse_api
.
env
.
$iq
;
var
$iq
=
converse_api
.
env
.
$iq
;
describe
(
"
The Registration Panel
"
,
function
()
{
describe
(
"
The Registration Panel
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
converse_api
.
listen
.
not
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
is not available unless allow_registration=true
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
is not available unless allow_registration=true
"
,
mock
.
initConverse
(
function
(
converse
)
{
runs
(
test_utils
.
openControlBox
);
runs
(
test_utils
.
openControlBox
);
...
...
spec/xmppstatus.js
View file @
176c7243
...
@@ -4,10 +4,6 @@
...
@@ -4,10 +4,6 @@
var
$
=
converse_api
.
env
.
jQuery
;
var
$
=
converse_api
.
env
.
jQuery
;
return
describe
(
"
The XMPPStatus model
"
,
function
()
{
return
describe
(
"
The XMPPStatus model
"
,
function
()
{
afterEach
(
function
()
{
converse_api
.
user
.
logout
();
test_utils
.
clearBrowserStorage
();
});
it
(
"
won't send <show>online when setting a custom status message
"
,
mock
.
initConverse
(
function
(
converse
)
{
it
(
"
won't send <show>online when setting a custom status message
"
,
mock
.
initConverse
(
function
(
converse
)
{
converse
.
xmppstatus
.
save
({
'
status
'
:
'
online
'
});
converse
.
xmppstatus
.
save
({
'
status
'
:
'
online
'
});
...
...
src/converse-api.js
View file @
176c7243
...
@@ -17,11 +17,9 @@
...
@@ -17,11 +17,9 @@
factory
);
factory
);
}(
this
,
function
(
$
,
_
,
moment
,
strophe
,
utils
,
converse
)
{
}(
this
,
function
(
$
,
_
,
moment
,
strophe
,
utils
,
converse
)
{
var
Strophe
=
strophe
.
Strophe
;
var
Strophe
=
strophe
.
Strophe
;
return
{
'
initialize
'
:
function
(
settings
,
callback
)
{
// API methods only available to plugins
return
converse
.
initialize
(
settings
,
callback
);
converse
.
api
=
{
},
'
log
'
:
converse
.
log
,
'
connection
'
:
{
'
connection
'
:
{
'
connected
'
:
function
()
{
'
connected
'
:
function
()
{
return
converse
.
connection
&&
converse
.
connection
.
connected
||
false
;
return
converse
.
connection
&&
converse
.
connection
.
connected
||
false
;
...
@@ -184,38 +182,21 @@
...
@@ -184,38 +182,21 @@
'
send
'
:
function
(
stanza
)
{
'
send
'
:
function
(
stanza
)
{
converse
.
connection
.
send
(
stanza
);
converse
.
connection
.
send
(
stanza
);
},
},
};
// The public API
return
{
'
initialize
'
:
function
(
settings
,
callback
)
{
return
converse
.
initialize
(
settings
,
callback
);
},
'
plugins
'
:
{
'
plugins
'
:
{
'
add
'
:
function
(
name
,
plugin
)
{
'
add
'
:
function
(
name
,
plugin
)
{
plugin
.
__name__
=
name
;
plugin
.
__name__
=
name
;
converse
.
pluggable
.
plugins
[
name
]
=
plugin
;
converse
.
pluggable
.
plugins
[
name
]
=
plugin
;
},
},
'
remove
'
:
function
(
name
)
{
'
remove
'
:
function
(
name
)
{
delete
converse
.
plugins
[
name
];
delete
converse
.
plug
gable
.
plug
ins
[
name
];
},
},
'
override
'
:
function
(
name
,
value
)
{
/* Helper method for overriding methods and attributes directly on the
* converse object. For Backbone objects, use instead the 'extend'
* method.
*
* If a method is overridden, then the original method will still be
* available via the __super__ attribute.
*
* name: The attribute being overridden.
* value: The value of the attribute being overridden.
*/
converse
.
_overrideAttribute
(
name
,
value
);
},
'
extend
'
:
function
(
obj
,
attributes
)
{
/* Helper method for overriding or extending Converse's Backbone Views or Models
*
* When a method is overriden, the original will still be available
* on the __super__ attribute of the object being overridden.
*
* obj: The Backbone View or Model
* attributes: A hash of attributes, such as you would pass to Backbone.Model.extend or Backbone.View.extend
*/
converse
.
_extendObject
(
obj
,
attributes
);
}
},
},
'
env
'
:
{
'
env
'
:
{
'
$build
'
:
strophe
.
$build
,
'
$build
'
:
strophe
.
$build
,
...
...
src/converse-bookmarks.js
View file @
176c7243
...
@@ -220,7 +220,7 @@
...
@@ -220,7 +220,7 @@
openBookmarkedRoom
:
function
(
bookmark
)
{
openBookmarkedRoom
:
function
(
bookmark
)
{
if
(
bookmark
.
get
(
'
autojoin
'
))
{
if
(
bookmark
.
get
(
'
autojoin
'
))
{
converse
_
api
.
rooms
.
open
(
bookmark
.
get
(
'
jid
'
),
bookmark
.
get
(
'
nick
'
));
converse
.
api
.
rooms
.
open
(
bookmark
.
get
(
'
jid
'
),
bookmark
.
get
(
'
nick
'
));
}
}
return
bookmark
;
return
bookmark
;
},
},
...
...
src/converse-mam.js
View file @
176c7243
...
@@ -228,7 +228,7 @@
...
@@ -228,7 +228,7 @@
converse
.
connection
.
sendIQ
(
stanza
,
null
,
errback
,
converse
.
message_archiving_timeout
);
converse
.
connection
.
sendIQ
(
stanza
,
null
,
errback
,
converse
.
message_archiving_timeout
);
};
};
_
.
extend
(
converse
_
api
,
{
_
.
extend
(
converse
.
api
,
{
/* Extend default converse.js API to add methods specific to MAM
/* Extend default converse.js API to add methods specific to MAM
*/
*/
'
archive
'
:
{
'
archive
'
:
{
...
...
src/converse-muc.js
View file @
176c7243
...
@@ -1841,7 +1841,7 @@
...
@@ -1841,7 +1841,7 @@
return
;
return
;
}
}
this
.
addSpinner
();
this
.
addSpinner
();
converse
_
api
.
archive
.
query
(
_
.
extend
(
options
,
{
'
groupchat
'
:
true
}),
converse
.
api
.
archive
.
query
(
_
.
extend
(
options
,
{
'
groupchat
'
:
true
}),
function
(
messages
)
{
function
(
messages
)
{
that
.
clearSpinner
();
that
.
clearSpinner
();
if
(
messages
.
length
)
{
if
(
messages
.
length
)
{
...
@@ -2360,9 +2360,9 @@
...
@@ -2360,9 +2360,9 @@
*/
*/
_
.
each
(
converse
.
auto_join_rooms
,
function
(
room
)
{
_
.
each
(
converse
.
auto_join_rooms
,
function
(
room
)
{
if
(
typeof
room
===
'
string
'
)
{
if
(
typeof
room
===
'
string
'
)
{
converse
_
api
.
rooms
.
open
(
room
);
converse
.
api
.
rooms
.
open
(
room
);
}
else
if
(
typeof
room
===
'
object
'
)
{
}
else
if
(
typeof
room
===
'
object
'
)
{
converse
_
api
.
rooms
.
open
(
room
.
jid
,
room
.
nick
);
converse
.
api
.
rooms
.
open
(
room
.
jid
,
room
.
nick
);
}
else
{
}
else
{
converse
.
log
(
'
Invalid room criteria specified for "auto_join_rooms"
'
,
'
error
'
);
converse
.
log
(
'
Invalid room criteria specified for "auto_join_rooms"
'
,
'
error
'
);
}
}
...
@@ -2385,7 +2385,7 @@
...
@@ -2385,7 +2385,7 @@
/* We extend the default converse.js API to add methods specific to MUC
/* We extend the default converse.js API to add methods specific to MUC
* chat rooms.
* chat rooms.
*/
*/
_
.
extend
(
converse
_
api
,
{
_
.
extend
(
converse
.
api
,
{
'
rooms
'
:
{
'
rooms
'
:
{
'
close
'
:
function
(
jids
)
{
'
close
'
:
function
(
jids
)
{
if
(
typeof
jids
===
"
undefined
"
)
{
if
(
typeof
jids
===
"
undefined
"
)
{
...
...
src/converse-ping.js
View file @
176c7243
...
@@ -19,8 +19,6 @@
...
@@ -19,8 +19,6 @@
"
use strict
"
;
"
use strict
"
;
// Strophe methods for building stanzas
// Strophe methods for building stanzas
var
Strophe
=
converse_api
.
env
.
Strophe
;
var
Strophe
=
converse_api
.
env
.
Strophe
;
// Other necessary globals
var
_
=
converse_api
.
env
.
_
;
converse_api
.
plugins
.
add
(
'
converse-ping
'
,
{
converse_api
.
plugins
.
add
(
'
converse-ping
'
,
{
...
@@ -89,15 +87,6 @@
...
@@ -89,15 +87,6 @@
}
}
};
};
_
.
extend
(
converse_api
,
{
/* We extend the default converse.js API to add a method specific
* to this plugin.
*/
'
ping
'
:
function
(
jid
)
{
converse
.
ping
(
jid
);
}
});
var
onConnected
=
function
()
{
var
onConnected
=
function
()
{
// Wrapper so that we can spy on registerPingHandler in tests
// Wrapper so that we can spy on registerPingHandler in tests
converse
.
registerPingHandler
();
converse
.
registerPingHandler
();
...
...
tests/mock.js
View file @
176c7243
...
@@ -77,6 +77,9 @@
...
@@ -77,6 +77,9 @@
mock
.
initConverse
=
function
(
func
,
settings
)
{
mock
.
initConverse
=
function
(
func
,
settings
)
{
return
function
()
{
return
function
()
{
window
.
localStorage
.
clear
();
window
.
sessionStorage
.
clear
();
var
converse
=
converse_api
.
initialize
(
_
.
extend
({
var
converse
=
converse_api
.
initialize
(
_
.
extend
({
i18n
:
window
.
locales
.
en
,
i18n
:
window
.
locales
.
en
,
auto_subscribe
:
false
,
auto_subscribe
:
false
,
...
...
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