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
e80f001b
Commit
e80f001b
authored
Sep 22, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow bookmarks to be removed from rooms
Refactored the code a bit in the process.
parent
7ca79437
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
164 additions
and
79 deletions
+164
-79
spec/bookmarks.js
spec/bookmarks.js
+67
-5
src/converse-bookmarks.js
src/converse-bookmarks.js
+97
-74
No files found.
spec/bookmarks.js
View file @
e80f001b
...
...
@@ -27,7 +27,6 @@
var
view
=
converse
.
chatboxviews
.
get
(
jid
);
spyOn
(
view
,
'
renderBookmarkForm
'
).
andCallThrough
();
spyOn
(
view
,
'
cancelConfiguration
'
).
andCallThrough
();
spyOn
(
view
,
'
onBookmarkError
'
).
andCallThrough
();
var
$bookmark
=
view
.
$el
.
find
(
'
.icon-pushpin
'
);
$bookmark
.
click
();
...
...
@@ -124,6 +123,11 @@
});
describe
(
"
when bookmarked
"
,
function
()
{
beforeEach
(
function
()
{
test_utils
.
closeAllChatBoxes
();
converse
.
bookmarks
.
reset
();
});
it
(
"
displays that it's bookmarked through its bookmark icon
"
,
function
()
{
runs
(
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
...
...
@@ -141,10 +145,68 @@
});
it
(
"
can be unbookmarked
"
,
function
()
{
// TODO
// Mock bookmark data received from the server.
// Open the room
// Click the bookmark icon to unbookmark
var
sent_stanza
,
IQ_id
;
var
sendIQ
=
converse
.
connection
.
sendIQ
;
spyOn
(
converse
.
connection
,
'
sendIQ
'
).
andCallFake
(
function
(
iq
,
callback
,
errback
)
{
sent_stanza
=
iq
;
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
spyOn
(
converse
.
connection
,
'
getUniqueId
'
).
andCallThrough
();
runs
(
function
()
{
test_utils
.
openChatRoom
(
'
theplay
'
,
'
conference.shakespeare.lit
'
,
'
JC
'
);
});
waits
(
100
);
runs
(
function
()
{
var
jid
=
'
theplay@conference.shakespeare.lit
'
;
var
view
=
converse
.
chatboxviews
.
get
(
jid
);
spyOn
(
view
,
'
toggleBookmark
'
).
andCallThrough
();
spyOn
(
converse
.
bookmarks
,
'
sendBookmarkStanza
'
).
andCallThrough
();
view
.
delegateEvents
();
converse
.
bookmarks
.
create
({
'
jid
'
:
view
.
model
.
get
(
'
jid
'
),
'
autojoin
'
:
false
,
'
name
'
:
'
The Play
'
,
'
nick
'
:
'
Othello
'
});
expect
(
converse
.
bookmarks
.
length
).
toBe
(
1
);
view
.
model
.
save
(
'
bookmarked
'
,
true
);
var
$bookmark_icon
=
view
.
$
(
'
.icon-pushpin
'
);
expect
(
$bookmark_icon
.
hasClass
(
'
button-on
'
)).
toBeTruthy
();
$bookmark_icon
.
click
();
expect
(
converse
.
bookmarks
.
sendBookmarkStanza
).
toHaveBeenCalled
();
expect
(
$bookmark_icon
.
hasClass
(
'
button-on
'
)).
toBeFalsy
();
expect
(
view
.
toggleBookmark
).
toHaveBeenCalled
();
expect
(
converse
.
bookmarks
.
length
).
toBe
(
0
);
// Check that an IQ stanza is sent out, containing no
// conferences to bookmark (since we removed the one and
// only bookmark).
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
"
<iq type='set' from='dummy@localhost/resource' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
"
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
"
+
"
<publish node='storage:bookmarks'>
"
+
"
<item id='current'>
"
+
"
<storage xmlns='storage:bookmarks'/>
"
+
"
</item>
"
+
"
</publish>
"
+
"
<publish-options>
"
+
"
<x xmlns='jabber:x:data' type='submit'>
"
+
"
<field var='FORM_TYPE' type='hidden'>
"
+
"
<value>http://jabber.org/protocol/pubsub#publish-options</value>
"
+
"
</field>
"
+
"
<field var='pubsub#persist_items'>
"
+
"
<value>true</value>
"
+
"
</field>
"
+
"
<field var='pubsub#access_model'>
"
+
"
<value>whitelist</value>
"
+
"
</field>
"
+
"
</x>
"
+
"
</publish-options>
"
+
"
</pubsub>
"
+
"
</iq>
"
);
});
});
});
});
...
...
src/converse-bookmarks.js
View file @
e80f001b
This diff is collapsed.
Click to expand it.
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