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
278c2c42
Commit
278c2c42
authored
Aug 18, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for the live filter functionality. updates #212
parent
71069790
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
185 additions
and
69 deletions
+185
-69
converse.js
converse.js
+1
-1
spec/chatbox.js
spec/chatbox.js
+2
-2
spec/controlbox.js
spec/controlbox.js
+138
-56
spec/minchats.js
spec/minchats.js
+1
-2
tests/mock.js
tests/mock.js
+8
-0
tests/utils.js
tests/utils.js
+35
-8
No files found.
converse.js
View file @
278c2c42
...
@@ -3479,7 +3479,7 @@
...
@@ -3479,7 +3479,7 @@
var
t
=
this
.
$
(
'
.filter-type
'
).
val
();
var
t
=
this
.
$
(
'
.filter-type
'
).
val
();
$
(
ev
.
target
)[
this
.
tog
(
q
)](
'
x
'
);
$
(
ev
.
target
)[
this
.
tog
(
q
)](
'
x
'
);
this
.
filter
(
q
,
t
);
this
.
filter
(
q
,
t
);
},
5
00
),
},
3
00
),
clearFilter
:
function
(
ev
)
{
clearFilter
:
function
(
ev
)
{
if
(
ev
&&
ev
.
preventDefault
)
{
if
(
ev
&&
ev
.
preventDefault
)
{
...
...
spec/chatbox.js
View file @
278c2c42
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
test_utils
.
removeControlBox
();
test_utils
.
removeControlBox
();
test_utils
.
clearBrowserStorage
();
test_utils
.
clearBrowserStorage
();
test_utils
.
initConverse
();
test_utils
.
initConverse
();
test_utils
.
createContacts
();
test_utils
.
createContacts
(
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
();
test_utils
.
openContactsPanel
();
});
});
...
@@ -684,7 +684,7 @@
...
@@ -684,7 +684,7 @@
test_utils
.
removeControlBox
();
test_utils
.
removeControlBox
();
converse
.
roster
.
browserStorage
.
_clear
();
converse
.
roster
.
browserStorage
.
_clear
();
test_utils
.
initConverse
();
test_utils
.
initConverse
();
test_utils
.
createContacts
();
test_utils
.
createContacts
(
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
();
test_utils
.
openContactsPanel
();
});
});
...
...
spec/controlbox.js
View file @
278c2c42
...
@@ -122,51 +122,144 @@
...
@@ -122,51 +122,144 @@
},
converse
));
},
converse
));
},
converse
,
mock
,
test_utils
));
},
converse
,
mock
,
test_utils
));
describe
(
"
The Contacts Roster
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
describe
(
"
The Contacts Roster
"
,
$
.
proxy
(
function
(
mock
,
utils
)
{
function
_clearContacts
()
{
utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
}
describe
(
"
A Roster Group
"
,
$
.
proxy
(
function
()
{
describe
(
"
The live filter
"
,
$
.
proxy
(
function
()
{
it
(
"
will only appear when roster contacts flow over the visible area
"
,
$
.
proxy
(
function
()
{
_clearContacts
();
var
$filter
=
converse
.
rosterview
.
$
(
'
.roster-filter
'
);
var
names
=
mock
.
cur_names
;
expect
(
$filter
.
length
).
toBe
(
1
);
expect
(
$filter
.
is
(
'
:visible
'
)).
toBeFalsy
();
for
(
i
=
0
;
i
<
names
.
length
;
i
++
)
{
converse
.
roster
.
create
({
ask
:
null
,
fullname
:
names
[
i
],
jid
:
names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
requesting
:
'
false
'
,
subscription
:
'
both
'
});
converse
.
rosterview
.
update
();
// XXX: Will normally called as event handler
if
(
converse
.
rosterview
.
$
(
'
.roster-contacts
'
).
hasScrollBar
())
{
expect
(
$filter
.
is
(
'
:visible
'
)).
toBeTruthy
();
}
else
{
expect
(
$filter
.
is
(
'
:visible
'
)).
toBeFalsy
();
}
}
},
converse
));
beforeEach
(
function
()
{
it
(
"
can be used to filter the contacts shown
"
,
function
()
{
converse
.
roster_groups
=
true
;
converse
.
roster_groups
=
true
;
_clearContacts
();
utils
.
createGroupedContacts
();
var
$filter
=
converse
.
rosterview
.
$
(
'
.roster-filter
'
);
var
$roster
=
converse
.
rosterview
.
$
(
'
.roster-contacts
'
);
runs
(
function
()
{
expect
(
$roster
.
find
(
'
dd:visible
'
).
length
).
toBe
(
15
);
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
5
);
$filter
.
val
(
"
candice
"
);
expect
(
$roster
.
find
(
'
dd:visible
'
).
length
).
toBe
(
15
);
// because no keydown event
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
5
);
// ditto
$filter
.
trigger
(
'
keydown
'
);
});
});
waits
(
350
);
// Needed, due to debounce
runs
(
function
()
{
expect
(
$roster
.
find
(
'
dd:visible
'
).
length
).
toBe
(
1
);
expect
(
$roster
.
find
(
'
dd:visible
'
).
eq
(
0
).
text
().
trim
()).
toBe
(
'
Candice van der Knijff
'
);
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
1
);
expect
(
$roster
.
find
(
'
dt:visible
'
).
eq
(
0
).
text
()).
toBe
(
'
colleagues
'
);
$filter
.
val
(
"
an
"
);
$filter
.
trigger
(
'
keydown
'
);
});
waits
(
350
);
// Needed, due to debounce
runs
(
function
()
{
expect
(
$roster
.
find
(
'
dd:visible
'
).
length
).
toBe
(
5
);
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
4
);
afterEach
(
function
()
{
$filter
.
val
(
"
xxx
"
);
$filter
.
trigger
(
'
keydown
'
);
});
waits
(
350
);
// Needed, due to debounce
runs
(
function
()
{
expect
(
$roster
.
find
(
'
dd:visible
'
).
length
).
toBe
(
0
);
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
0
);
});
converse
.
roster_groups
=
false
;
converse
.
roster_groups
=
false
;
});
});
function
_clearContacts
()
{
it
(
"
can be used to filter the groups shown
"
,
function
()
{
test_utils
.
clearBrowserStorage
();
converse
.
roster_groups
=
true
;
converse
.
rosterview
.
model
.
reset
();
_clearContacts
();
}
utils
.
createGroupedContacts
();
var
$filter
=
converse
.
rosterview
.
$
(
'
.roster-filter
'
);
var
$roster
=
converse
.
rosterview
.
$
(
'
.roster-contacts
'
);
var
$type
=
converse
.
rosterview
.
$
(
'
.filter-type
'
);
$type
.
val
(
'
groups
'
);
runs
(
function
()
{
expect
(
$roster
.
find
(
'
dd:visible
'
).
length
).
toBe
(
15
);
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
5
);
$filter
.
val
(
"
colleagues
"
);
expect
(
$roster
.
find
(
'
dd:visible
'
).
length
).
toBe
(
15
);
// because no keydown event
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
5
);
// ditto
$filter
.
trigger
(
'
keydown
'
);
});
waits
(
350
);
// Needed, due to debounce
runs
(
function
()
{
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
1
);
expect
(
$roster
.
find
(
'
dt:visible
'
).
eq
(
0
).
text
()).
toBe
(
'
colleagues
'
);
// Check that all contacts under the group are shown
expect
(
$roster
.
find
(
'
dt:visible
'
).
nextUntil
(
'
dt
'
,
'
dd:hidden
'
).
length
).
toBe
(
0
);
$filter
.
val
(
"
xxx
"
);
$filter
.
trigger
(
'
keydown
'
);
});
waits
(
350
);
// Needed, due to debounce
runs
(
function
()
{
expect
(
$roster
.
find
(
'
dt:visible
'
).
length
).
toBe
(
0
);
});
converse
.
roster_groups
=
false
;
});
it
(
"
has a button with which its contents can be cleared
"
,
function
()
{
converse
.
roster_groups
=
true
;
_clearContacts
();
utils
.
createGroupedContacts
();
var
$filter
=
converse
.
rosterview
.
$
(
'
.roster-filter
'
);
var
$roster
=
converse
.
rosterview
.
$
(
'
.roster-contacts
'
);
runs
(
function
()
{
$filter
.
val
(
"
xxx
"
);
$filter
.
trigger
(
'
keydown
'
);
expect
(
$filter
.
hasClass
(
"
x
"
)).
toBeFalsy
();
});
waits
(
350
);
// Needed, due to debounce
runs
(
function
()
{
expect
(
$filter
.
hasClass
(
"
x
"
)).
toBeTruthy
();
$filter
.
addClass
(
"
onX
"
).
click
();
expect
(
$filter
.
val
()).
toBe
(
""
);
});
converse
.
roster_groups
=
false
;
});
},
converse
));
describe
(
"
A Roster Group
"
,
$
.
proxy
(
function
()
{
beforeEach
(
function
()
{
converse
.
roster_groups
=
true
;
});
afterEach
(
function
()
{
converse
.
roster_groups
=
false
;
});
it
(
"
can be used to organize existing contacts
"
,
$
.
proxy
(
function
()
{
it
(
"
can be used to organize existing contacts
"
,
$
.
proxy
(
function
()
{
_clearContacts
();
_clearContacts
();
var
i
=
0
,
j
=
0
,
t
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
update
'
).
andCallThrough
();
spyOn
(
this
.
rosterview
,
'
update
'
).
andCallThrough
();
converse
.
rosterview
.
render
();
converse
.
rosterview
.
render
();
utils
.
createContacts
(
'
pending
'
);
test_utils
.
createContacts
(
'
pending
'
);
utils
.
createContacts
(
'
requesting
'
);
test_utils
.
createContacts
(
'
requesting
'
);
utils
.
createGroupedContacts
();
var
groups
=
{
'
colleagues
'
:
3
,
'
friends & acquaintences
'
:
3
,
'
Family
'
:
4
,
'
ænemies
'
:
3
,
'
Ungrouped
'
:
2
};
_
.
each
(
_
.
keys
(
groups
),
$
.
proxy
(
function
(
name
)
{
j
=
i
;
for
(
i
=
j
;
i
<
j
+
groups
[
name
];
i
++
)
{
this
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
both
'
,
ask
:
null
,
groups
:
name
===
'
ungrouped
'
?
[]
:
[
name
],
fullname
:
mock
.
cur_names
[
i
]
});
}
},
converse
));
// Check that the groups appear alphabetically and that
// Check that the groups appear alphabetically and that
// requesting and pending contacts are last.
// requesting and pending contacts are last.
var
group_titles
=
$
.
map
(
this
.
rosterview
.
$el
.
find
(
'
dt
'
),
function
(
o
)
{
return
$
(
o
).
text
().
trim
();
});
var
group_titles
=
$
.
map
(
this
.
rosterview
.
$el
.
find
(
'
dt
'
),
function
(
o
)
{
return
$
(
o
).
text
().
trim
();
});
...
@@ -180,7 +273,7 @@
...
@@ -180,7 +273,7 @@
"
Pending contacts
"
"
Pending contacts
"
]);
]);
// Check that usernames appear alphabetically per group
// Check that usernames appear alphabetically per group
_
.
each
(
_
.
keys
(
groups
),
$
.
proxy
(
function
(
name
)
{
_
.
each
(
_
.
keys
(
mock
.
groups
),
$
.
proxy
(
function
(
name
)
{
var
$contacts
=
this
.
rosterview
.
$
(
'
dt.roster-group[data-group="
'
+
name
+
'
"]
'
).
nextUntil
(
'
dt
'
,
'
dd
'
);
var
$contacts
=
this
.
rosterview
.
$
(
'
dt.roster-group[data-group="
'
+
name
+
'
"]
'
).
nextUntil
(
'
dt
'
,
'
dd
'
);
var
names
=
$
.
map
(
$contacts
,
function
(
o
)
{
return
$
(
o
).
text
().
trim
();
});
var
names
=
$
.
map
(
$contacts
,
function
(
o
)
{
return
$
(
o
).
text
().
trim
();
});
expect
(
names
).
toEqual
(
_
.
clone
(
names
).
sort
());
expect
(
names
).
toEqual
(
_
.
clone
(
names
).
sort
());
...
@@ -189,7 +282,7 @@
...
@@ -189,7 +282,7 @@
it
(
"
can share contacts with other roster groups
"
,
$
.
proxy
(
function
()
{
it
(
"
can share contacts with other roster groups
"
,
$
.
proxy
(
function
()
{
_clearContacts
();
_clearContacts
();
var
i
=
0
,
j
=
0
,
t
;
var
i
=
0
,
j
=
0
;
spyOn
(
converse
,
'
emit
'
);
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
rosterview
,
'
update
'
).
andCallThrough
();
spyOn
(
this
.
rosterview
,
'
update
'
).
andCallThrough
();
converse
.
rosterview
.
render
();
converse
.
rosterview
.
render
();
...
@@ -213,7 +306,7 @@
...
@@ -213,7 +306,7 @@
},
converse
));
},
converse
));
it
(
"
remembers whether it is closed or opened
"
,
$
.
proxy
(
function
()
{
it
(
"
remembers whether it is closed or opened
"
,
$
.
proxy
(
function
()
{
var
i
=
0
,
j
=
0
,
t
;
var
i
=
0
,
j
=
0
;
var
groups
=
{
var
groups
=
{
'
colleagues
'
:
3
,
'
colleagues
'
:
3
,
'
friends & acquaintences
'
:
3
,
'
friends & acquaintences
'
:
3
,
...
@@ -243,14 +336,14 @@
...
@@ -243,14 +336,14 @@
describe
(
"
Pending Contacts
"
,
$
.
proxy
(
function
()
{
describe
(
"
Pending Contacts
"
,
$
.
proxy
(
function
()
{
function
_clearContacts
()
{
function
_clearContacts
()
{
test_
utils
.
clearBrowserStorage
();
utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
converse
.
rosterview
.
model
.
reset
();
}
}
function
_addContacts
()
{
function
_addContacts
()
{
_clearContacts
();
_clearContacts
();
// Must be initialized, so that render is called and documentFragment set up.
// Must be initialized, so that render is called and documentFragment set up.
test_
utils
.
createContacts
(
'
pending
'
).
openControlBox
().
openContactsPanel
();
utils
.
createContacts
(
'
pending
'
).
openControlBox
().
openContactsPanel
();
}
}
it
(
"
can be collapsed under their own header
"
,
$
.
proxy
(
function
()
{
it
(
"
can be collapsed under their own header
"
,
$
.
proxy
(
function
()
{
...
@@ -350,13 +443,13 @@
...
@@ -350,13 +443,13 @@
describe
(
"
Existing Contacts
"
,
$
.
proxy
(
function
()
{
describe
(
"
Existing Contacts
"
,
$
.
proxy
(
function
()
{
function
_clearContacts
()
{
function
_clearContacts
()
{
test_
utils
.
clearBrowserStorage
();
utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
converse
.
rosterview
.
model
.
reset
();
}
}
var
_addContacts
=
function
()
{
var
_addContacts
=
function
()
{
_clearContacts
();
_clearContacts
();
test_utils
.
createContacts
(
).
openControlBox
().
openContactsPanel
();
utils
.
createContacts
(
'
current
'
).
openControlBox
().
openContactsPanel
();
};
};
it
(
"
can be collapsed under their own header
"
,
$
.
proxy
(
function
()
{
it
(
"
can be collapsed under their own header
"
,
$
.
proxy
(
function
()
{
...
@@ -561,13 +654,13 @@
...
@@ -561,13 +654,13 @@
describe
(
"
Requesting Contacts
"
,
$
.
proxy
(
function
()
{
describe
(
"
Requesting Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
runs
(
function
()
{
runs
(
function
()
{
test_
utils
.
clearBrowserStorage
();
utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
converse
.
rosterview
.
model
.
reset
();
test_
utils
.
createContacts
(
'
requesting
'
).
openControlBox
();
utils
.
createContacts
(
'
requesting
'
).
openControlBox
();
});
});
waits
(
50
);
waits
(
50
);
runs
(
function
()
{
runs
(
function
()
{
test_
utils
.
openContactsPanel
();
utils
.
openContactsPanel
();
});
});
},
converse
));
},
converse
));
...
@@ -646,7 +739,7 @@
...
@@ -646,7 +739,7 @@
spyOn
(
converse
,
'
emit
'
);
spyOn
(
converse
,
'
emit
'
);
spyOn
(
this
.
connection
.
roster
,
'
unauthorize
'
);
spyOn
(
this
.
connection
.
roster
,
'
unauthorize
'
);
spyOn
(
window
,
'
confirm
'
).
andReturn
(
true
);
spyOn
(
window
,
'
confirm
'
).
andReturn
(
true
);
test_
utils
.
createContacts
(
'
requesting
'
).
openControlBox
();
utils
.
createContacts
(
'
requesting
'
).
openControlBox
();
var
name
=
mock
.
req_names
.
sort
()[
1
];
var
name
=
mock
.
req_names
.
sort
()[
1
];
var
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
converse
.
rosterview
.
$el
.
find
(
"
.req-contact-name:contains('
"
+
name
+
"
')
"
)
converse
.
rosterview
.
$el
.
find
(
"
.req-contact-name:contains('
"
+
name
+
"
')
"
)
...
@@ -661,10 +754,10 @@
...
@@ -661,10 +754,10 @@
describe
(
"
All Contacts
"
,
$
.
proxy
(
function
()
{
describe
(
"
All Contacts
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
test_
utils
.
clearBrowserStorage
();
utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
converse
.
rosterview
.
model
.
reset
();
test_
utils
.
createContacts
(
'
all
'
).
openControlBox
();
utils
.
createContacts
(
'
all
'
).
openControlBox
();
test_
utils
.
openContactsPanel
();
utils
.
openContactsPanel
();
},
converse
));
},
converse
));
it
(
"
are saved to, and can be retrieved from, browserStorage
"
,
$
.
proxy
(
function
()
{
it
(
"
are saved to, and can be retrieved from, browserStorage
"
,
$
.
proxy
(
function
()
{
...
@@ -688,17 +781,6 @@
...
@@ -688,17 +781,6 @@
expect
(
_
.
isEqual
(
new_attrs
.
sort
(),
old_attrs
.
sort
())).
toEqual
(
true
);
expect
(
_
.
isEqual
(
new_attrs
.
sort
(),
old_attrs
.
sort
())).
toEqual
(
true
);
}
}
},
converse
));
},
converse
));
afterEach
(
$
.
proxy
(
function
()
{
// Contacts retrieved from browserStorage have chat_status of
// "offline".
// In the next test suite, we need some online contacts, so
// we make some online now
for
(
i
=
0
;
i
<
5
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
this
.
roster
.
get
(
jid
).
set
(
'
chat_status
'
,
'
online
'
);
}
},
converse
));
},
converse
));
},
converse
));
},
converse
,
mock
,
test_utils
));
},
converse
,
mock
,
test_utils
));
...
...
spec/minchats.js
View file @
278c2c42
...
@@ -8,14 +8,13 @@
...
@@ -8,14 +8,13 @@
);
);
}
(
this
,
function
(
mock
,
test_utils
)
{
}
(
this
,
function
(
mock
,
test_utils
)
{
return
describe
(
"
The Minimized Chats Widget
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
return
describe
(
"
The Minimized Chats Widget
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
runs
(
function
()
{
runs
(
function
()
{
test_utils
.
closeAllChatBoxes
();
test_utils
.
closeAllChatBoxes
();
test_utils
.
removeControlBox
();
test_utils
.
removeControlBox
();
converse
.
roster
.
browserStorage
.
_clear
();
converse
.
roster
.
browserStorage
.
_clear
();
test_utils
.
initConverse
();
test_utils
.
initConverse
();
test_utils
.
createContacts
();
test_utils
.
createContacts
(
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
();
test_utils
.
openContactsPanel
();
converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
...
...
tests/mock.js
View file @
278c2c42
...
@@ -20,6 +20,14 @@
...
@@ -20,6 +20,14 @@
];
];
mock
.
num_contacts
=
mock
.
req_names
.
length
+
mock
.
pend_names
.
length
+
mock
.
cur_names
.
length
;
mock
.
num_contacts
=
mock
.
req_names
.
length
+
mock
.
pend_names
.
length
+
mock
.
cur_names
.
length
;
mock
.
groups
=
{
'
colleagues
'
:
3
,
'
friends & acquaintences
'
:
3
,
'
Family
'
:
4
,
'
ænemies
'
:
3
,
'
Ungrouped
'
:
2
};
mock
.
chatroom_names
=
[
mock
.
chatroom_names
=
[
'
Dyon van de Wege
'
,
'
Thomas Kalb
'
,
'
Dirk Theissen
'
,
'
Felix Hofmann
'
,
'
Ka Lek
'
,
'
Anne Ebersbacher
'
'
Dyon van de Wege
'
,
'
Thomas Kalb
'
,
'
Dirk Theissen
'
,
'
Felix Hofmann
'
,
'
Ka Lek
'
,
'
Anne Ebersbacher
'
];
];
...
...
tests/utils.js
View file @
278c2c42
...
@@ -110,9 +110,12 @@
...
@@ -110,9 +110,12 @@
view
.
model
.
messages
.
browserStorage
.
_clear
();
view
.
model
.
messages
.
browserStorage
.
_clear
();
};
};
utils
.
createContacts
=
function
(
type
)
{
utils
.
createContacts
=
function
(
type
,
length
)
{
// Create current (as opposed to requesting or pending) contacts
/* Create current (as opposed to requesting or pending) contacts
// for the user's roster.
* for the user's roster.
*
* These contacts are not grouped. See below.
*/
var
names
;
var
names
;
if
(
type
===
'
requesting
'
)
{
if
(
type
===
'
requesting
'
)
{
names
=
mock
.
req_names
;
names
=
mock
.
req_names
;
...
@@ -124,16 +127,22 @@
...
@@ -124,16 +127,22 @@
subscription
=
'
none
'
;
subscription
=
'
none
'
;
requesting
=
false
;
requesting
=
false
;
ask
=
'
subscribe
'
;
ask
=
'
subscribe
'
;
}
else
if
(
type
===
'
all
'
)
{
}
else
if
(
type
===
'
current
'
)
{
this
.
createContacts
().
createContacts
(
'
request
'
).
createContacts
(
'
pending
'
);
return
this
;
}
else
{
names
=
mock
.
cur_names
;
names
=
mock
.
cur_names
;
subscription
=
'
both
'
;
subscription
=
'
both
'
;
requesting
=
false
;
requesting
=
false
;
ask
=
null
;
ask
=
null
;
}
else
if
(
type
===
'
all
'
)
{
this
.
createContacts
(
'
current
'
).
createContacts
(
'
requesting
'
).
createContacts
(
'
pending
'
);
return
this
;
}
else
{
throw
"
Need to specify the type of contact to create
"
;
}
}
for
(
i
=
0
;
i
<
names
.
length
;
i
++
)
{
if
(
typeof
length
===
'
undefined
'
)
{
length
=
names
.
length
;
}
for
(
i
=
0
;
i
<
length
;
i
++
)
{
converse
.
roster
.
create
({
converse
.
roster
.
create
({
ask
:
ask
,
ask
:
ask
,
fullname
:
names
[
i
],
fullname
:
names
[
i
],
...
@@ -145,6 +154,24 @@
...
@@ -145,6 +154,24 @@
return
this
;
return
this
;
};
};
utils
.
createGroupedContacts
=
function
()
{
/* Create grouped contacts
*/
var
i
=
0
,
j
=
0
;
_
.
each
(
_
.
keys
(
mock
.
groups
),
$
.
proxy
(
function
(
name
)
{
j
=
i
;
for
(
i
=
j
;
i
<
j
+
mock
.
groups
[
name
];
i
++
)
{
converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
subscription
:
'
both
'
,
ask
:
null
,
groups
:
name
===
'
ungrouped
'
?
[]
:
[
name
],
fullname
:
mock
.
cur_names
[
i
]
});
}
},
converse
));
};
utils
.
sendMessage
=
function
(
chatboxview
,
message
)
{
utils
.
sendMessage
=
function
(
chatboxview
,
message
)
{
chatboxview
.
$el
.
find
(
'
.chat-textarea
'
).
val
(
message
);
chatboxview
.
$el
.
find
(
'
.chat-textarea
'
).
val
(
message
);
chatboxview
.
$el
.
find
(
'
textarea.chat-textarea
'
).
trigger
(
$
.
Event
(
'
keypress
'
,
{
keyCode
:
13
}));
chatboxview
.
$el
.
find
(
'
textarea.chat-textarea
'
).
trigger
(
$
.
Event
(
'
keypress
'
,
{
keyCode
:
13
}));
...
...
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