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
1dbe0ed8
Commit
1dbe0ed8
authored
Jul 21, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trying to work around timezone issues.
Causing tests to fail on Travis.
parent
8e7dba9b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
46 deletions
+17
-46
spec/mam.js
spec/mam.js
+17
-46
No files found.
spec/mam.js
View file @
1dbe0ed8
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
var
$iq
=
converse_api
.
env
.
$iq
;
var
$iq
=
converse_api
.
env
.
$iq
;
var
$pres
=
converse_api
.
env
.
$pres
;
var
$pres
=
converse_api
.
env
.
$pres
;
var
$msg
=
converse_api
.
env
.
$msg
;
var
$msg
=
converse_api
.
env
.
$msg
;
var
moment
=
converse_api
.
env
.
moment
;
// See: https://xmpp.org/rfcs/rfc3921.html
// See: https://xmpp.org/rfcs/rfc3921.html
describe
(
"
Message Archive Management
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
describe
(
"
Message Archive Management
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
...
@@ -74,14 +75,11 @@
...
@@ -74,14 +75,11 @@
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
});
}
}
// Mock the browser's method for returning the timezone
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
getTimezoneOffset
=
Date
.
prototype
.
getTimezoneOffset
;
var
end
=
'
2010-07-07T13:23:54Z
'
;
Date
.
prototype
.
getTimezoneOffset
=
function
()
{
return
-
120
;
};
converse_api
.
archive
.
query
({
converse_api
.
archive
.
query
({
'
start
'
:
'
2010-06-07T00:00:00Z
'
,
'
start
'
:
start
,
'
end
'
:
'
2010-07-07T13:23:54Z
'
'
end
'
:
end
});
});
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
var
queryid
=
$
(
sent_stanza
.
toString
()).
find
(
'
query
'
).
attr
(
'
queryid
'
);
...
@@ -93,17 +91,15 @@
...
@@ -93,17 +91,15 @@
"
<value>urn:xmpp:mam:0</value>
"
+
"
<value>urn:xmpp:mam:0</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
<field var='start'>
"
+
"
<field var='start'>
"
+
"
<value>
2010-06-07T02:00:00+02:00
</value>
"
+
"
<value>
"
+
moment
(
start
).
format
()
+
"
</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
<field var='end'>
"
+
"
<field var='end'>
"
+
"
<value>
2010-07-07T15:23:54+02:00
</value>
"
+
"
<value>
"
+
moment
(
end
).
format
()
+
"
</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
</x>
"
+
"
</x>
"
+
"
</query>
"
+
"
</query>
"
+
"
</iq>
"
"
</iq>
"
);
);
// Restore
Date
.
prototype
.
getTimezoneOffset
=
getTimezoneOffset
;
});
});
it
(
"
throws a TypeError if an invalid date is provided
"
,
function
()
{
it
(
"
throws a TypeError if an invalid date is provided
"
,
function
()
{
...
@@ -122,12 +118,8 @@
...
@@ -122,12 +118,8 @@
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
});
}
}
// Mock the browser's method for returning the timezone
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
getTimezoneOffset
=
Date
.
prototype
.
getTimezoneOffset
;
converse_api
.
archive
.
query
({
'
start
'
:
start
});
Date
.
prototype
.
getTimezoneOffset
=
function
()
{
return
-
120
;
};
converse_api
.
archive
.
query
({
'
start
'
:
'
2010-06-07T00:00:00Z
'
});
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
+
"
'>
"
+
...
@@ -137,14 +129,12 @@
...
@@ -137,14 +129,12 @@
"
<value>urn:xmpp:mam:0</value>
"
+
"
<value>urn:xmpp:mam:0</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
<field var='start'>
"
+
"
<field var='start'>
"
+
"
<value>
2010-06-07T02:00:00+02:00
</value>
"
+
"
<value>
"
+
moment
(
start
).
format
()
+
"
</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
</x>
"
+
"
</x>
"
+
"
</query>
"
+
"
</query>
"
+
"
</iq>
"
"
</iq>
"
);
);
// Restore
Date
.
prototype
.
getTimezoneOffset
=
getTimezoneOffset
;
});
});
it
(
"
can be used to query for a limited set of results
"
,
function
()
{
it
(
"
can be used to query for a limited set of results
"
,
function
()
{
...
@@ -157,12 +147,8 @@
...
@@ -157,12 +147,8 @@
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
});
}
}
// Mock the browser's method for returning the timezone
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
getTimezoneOffset
=
Date
.
prototype
.
getTimezoneOffset
;
converse_api
.
archive
.
query
({
'
start
'
:
start
,
'
max
'
:
10
});
Date
.
prototype
.
getTimezoneOffset
=
function
()
{
return
-
120
;
};
converse_api
.
archive
.
query
({
'
start
'
:
'
2010-06-07T00:00:00Z
'
,
'
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
+
"
'>
"
+
...
@@ -172,7 +158,7 @@
...
@@ -172,7 +158,7 @@
"
<value>urn:xmpp:mam:0</value>
"
+
"
<value>urn:xmpp:mam:0</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
<field var='start'>
"
+
"
<field var='start'>
"
+
"
<value>
2010-06-07T02:00:00+02:00
</value>
"
+
"
<value>
"
+
moment
(
start
).
format
()
+
"
</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
</x>
"
+
"
</x>
"
+
"
<set xmlns='http://jabber.org/protocol/rsm'>
"
+
"
<set xmlns='http://jabber.org/protocol/rsm'>
"
+
...
@@ -181,8 +167,6 @@
...
@@ -181,8 +167,6 @@
"
</query>
"
+
"
</query>
"
+
"
</iq>
"
"
</iq>
"
);
);
// Restore
Date
.
prototype
.
getTimezoneOffset
=
getTimezoneOffset
;
});
});
it
(
"
can be used to page through results
"
,
function
()
{
it
(
"
can be used to page through results
"
,
function
()
{
...
@@ -195,13 +179,9 @@
...
@@ -195,13 +179,9 @@
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
});
}
}
// Mock the browser's method for returning the timezone
var
start
=
'
2010-06-07T00:00:00Z
'
;
var
getTimezoneOffset
=
Date
.
prototype
.
getTimezoneOffset
;
Date
.
prototype
.
getTimezoneOffset
=
function
()
{
return
-
120
;
};
converse_api
.
archive
.
query
({
converse_api
.
archive
.
query
({
'
start
'
:
'
2010-06-07T00:00:00Z
'
,
'
start
'
:
start
,
'
after
'
:
'
09af3-cc343-b409f
'
,
'
after
'
:
'
09af3-cc343-b409f
'
,
'
max
'
:
10
'
max
'
:
10
});
});
...
@@ -214,7 +194,7 @@
...
@@ -214,7 +194,7 @@
"
<value>urn:xmpp:mam:0</value>
"
+
"
<value>urn:xmpp:mam:0</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
<field var='start'>
"
+
"
<field var='start'>
"
+
"
<value>
2010-06-07T02:00:00+02:00
</value>
"
+
"
<value>
"
+
moment
(
start
).
format
()
+
"
</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
</x>
"
+
"
</x>
"
+
"
<set xmlns='http://jabber.org/protocol/rsm'>
"
+
"
<set xmlns='http://jabber.org/protocol/rsm'>
"
+
...
@@ -224,8 +204,6 @@
...
@@ -224,8 +204,6 @@
"
</query>
"
+
"
</query>
"
+
"
</iq>
"
"
</iq>
"
);
);
// Restore
Date
.
prototype
.
getTimezoneOffset
=
getTimezoneOffset
;
});
});
it
(
"
accepts
\"
before
\"
with an empty string as value to reverse the order
"
,
function
()
{
it
(
"
accepts
\"
before
\"
with an empty string as value to reverse the order
"
,
function
()
{
...
@@ -271,11 +249,6 @@
...
@@ -271,11 +249,6 @@
sent_stanza
=
iq
;
sent_stanza
=
iq
;
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
});
// Mock the browser's method for returning the timezone
var
getTimezoneOffset
=
Date
.
prototype
.
getTimezoneOffset
;
Date
.
prototype
.
getTimezoneOffset
=
function
()
{
return
-
120
;
};
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
'
;
...
@@ -293,7 +266,7 @@
...
@@ -293,7 +266,7 @@
"
<value>romeo@montague.lit</value>
"
+
"
<value>romeo@montague.lit</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
<field var='start'>
"
+
"
<field var='start'>
"
+
"
<value>
2010-06-07T02:00:00+02:00
</value>
"
+
"
<value>
"
+
moment
(
rsm
.
start
).
format
()
+
"
</value>
"
+
"
</field>
"
+
"
</field>
"
+
"
</x>
"
+
"
</x>
"
+
"
<set xmlns='http://jabber.org/protocol/rsm'>
"
+
"
<set xmlns='http://jabber.org/protocol/rsm'>
"
+
...
@@ -302,8 +275,6 @@
...
@@ -302,8 +275,6 @@
"
</query>
"
+
"
</query>
"
+
"
</iq>
"
"
</iq>
"
);
);
// Restore
Date
.
prototype
.
getTimezoneOffset
=
getTimezoneOffset
;
});
});
it
(
"
accepts a callback function, which it passes the messages and a Strophe.RSM object
"
,
function
()
{
it
(
"
accepts a callback function, which it passes the messages and a Strophe.RSM object
"
,
function
()
{
...
...
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