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
8525ee50
Commit
8525ee50
authored
Apr 13, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename RosterSpec.js to MainSpec.js
parent
ed86b22f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
123 deletions
+0
-123
spec/MainSpec.js
spec/MainSpec.js
+0
-0
spec/StorageSpec.js
spec/StorageSpec.js
+0
-123
No files found.
spec/
Roster
Spec.js
→
spec/
Main
Spec.js
View file @
8525ee50
File moved
spec/StorageSpec.js
deleted
100644 → 0
View file @
ed86b22f
(
function
(
root
,
factory
)
{
define
([
"
converse
"
],
function
(
xmppchat
)
{
return
factory
(
xmppchat
);
}
);
}
(
this
,
function
(
xmppchat
)
{
String
.
prototype
.
repeat
=
function
(
times
)
{
return
(
new
Array
(
times
+
1
)).
join
(
this
+
'
'
).
replace
(
/
\s
$/
,
''
);
};
return
describe
(
"
Local storage of messages and open chats
"
,
function
()
{
beforeEach
(
function
()
{
this
.
storage
=
new
xmppchat
.
ClientStorage
(
'
dummy@localhost
'
);
});
describe
(
"
open chat storage
"
,
function
()
{
beforeEach
(
function
()
{
// Removes all stored items
this
.
storage
.
flush
();
});
it
(
"
should by default not have any chats
"
,
function
()
{
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([]);
});
it
(
"
should be able to add chats
"
,
function
()
{
this
.
storage
.
addOpenChat
(
'
chat1@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([
'
chat1@localhost
'
]);
this
.
storage
.
addOpenChat
(
'
chat2@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([
'
chat1@localhost
'
,
'
chat2@localhost
'
]);
this
.
storage
.
addOpenChat
(
'
chat3@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([
'
chat1@localhost
'
,
'
chat2@localhost
'
,
'
chat3@localhost
'
]);
});
it
(
"
should be able to remove chats
"
,
function
()
{
this
.
storage
.
removeOpenChat
(
'
non-existing@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([]);
this
.
storage
.
addOpenChat
(
'
chat1@localhost
'
);
this
.
storage
.
addOpenChat
(
'
chat2@localhost
'
);
this
.
storage
.
addOpenChat
(
'
chat3@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([
'
chat1@localhost
'
,
'
chat2@localhost
'
,
'
chat3@localhost
'
]);
this
.
storage
.
removeOpenChat
(
'
chat2@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([
'
chat1@localhost
'
,
'
chat3@localhost
'
]);
this
.
storage
.
removeOpenChat
(
'
chat1@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([
'
chat3@localhost
'
]);
this
.
storage
.
removeOpenChat
(
'
chat3@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([]);
this
.
storage
.
removeOpenChat
(
'
non-existing@localhost
'
);
expect
(
this
.
storage
.
getOpenChats
()).
toEqual
([]);
});
});
describe
(
"
message storage
"
,
function
()
{
var
iso_regex
=
/
\d{4}
-
[
01
]\d
-
[
0-3
]\d
T
[
0-2
]\d
:
[
0-5
]\d
:
[
0-5
]\d\.\d
+
([
+-
][
0-2
]\d
:
[
0-5
]\d
|Z
)
/
;
it
(
"
should by default not have any messages
"
,
function
()
{
expect
(
this
.
storage
.
getMessages
(
'
chat@localhost
'
)).
toEqual
([]);
});
it
(
"
should be able to add and retrieve messages
"
,
function
()
{
var
i
,
jid
=
'
chat@localhost
'
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
var
msg
=
'
msg
'
.
repeat
(
i
+
1
);
this
.
storage
.
addMessage
(
jid
,
msg
,
'
to
'
);
// Check that message is returned
var
msgs
=
this
.
storage
.
getMessages
(
jid
);
expect
(
msgs
.
length
).
toEqual
(
i
+
1
);
expect
(
msgs
[
i
]).
toEqual
(
jasmine
.
any
(
String
));
// First two space separated strings are ISO date and direction
var
msg_arr
=
msgs
[
i
].
split
(
'
'
,
2
);
// Check that first string is ISO format
expect
(
msg_arr
[
0
]).
toMatch
(
iso_regex
);
expect
(
msg_arr
[
0
]).
toEqual
(
jasmine
.
any
(
String
));
expect
(
msg_arr
[
1
]).
toEqual
(
'
to
'
);
expect
(
msgs
[
i
].
replace
(
/
(
.*
?\s
.*
?\s)
/
,
''
)).
toEqual
(
msg
);
}
});
it
(
"
should be able to get last message
"
,
function
()
{
var
msg
=
this
.
storage
.
getLastMessage
(
'
chat@localhost
'
),
msg_arr
=
msg
.
split
(
'
'
,
2
);
expect
(
msg_arr
[
0
]).
toMatch
(
iso_regex
);
expect
(
msg_arr
[
0
]).
toEqual
(
jasmine
.
any
(
String
));
expect
(
msg_arr
[
1
]).
toEqual
(
'
to
'
);
expect
(
msg
.
replace
(
/
(
.*
?\s
.*
?\s)
/
,
''
)).
toEqual
(
'
msg
'
.
repeat
(
10
));
});
it
(
"
should be able to clear all messages
"
,
function
()
{
this
.
storage
.
clearMessages
(
'
chat@localhost
'
);
expect
(
this
.
storage
.
getMessages
(
'
chat@localhost
'
)).
toEqual
([]);
});
it
(
"
should not store more than 30 messages
"
,
function
()
{
var
i
,
msgs
;
for
(
i
=
0
;
i
<
100
;
i
++
)
{
this
.
storage
.
addMessage
(
'
chat@localhost
'
,
'
msg
'
,
'
to
'
);
}
msgs
=
this
.
storage
.
getMessages
(
'
chat@localhost
'
);
expect
(
msgs
.
length
).
toEqual
(
30
);
});
});
});
}));
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