Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LQDN Adminsys
generateur-slogans
Commits
005c1457
Verified
Commit
005c1457
authored
Nov 21, 2017
by
Thibaut Broggi
Browse files
Add a test for media share message
Fix bug on lqdn name depending on the social network used
parent
2bd670b9
Pipeline
#1707
passed with stages
in 2 minutes and 11 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
shareMessage.js
View file @
005c1457
...
...
@@ -25,6 +25,7 @@ module.exports = function(req) {
}
this
.
getTwitterLink
=
function
()
{
_lqdnName
=
"
@laquadrature
"
;
return
'
https://twitter.com/intent/tweet?text=
'
+
encodeURIComponent
(
this
.
getTitle
()
+
'
'
+
this
.
getContent
()
...
...
@@ -32,6 +33,7 @@ module.exports = function(req) {
}
this
.
getFacebookLink
=
function
()
{
_lqdnName
=
"
@laquadrature
"
;
return
'
https://www.facebook.com/sharer/sharer.php?u=
'
+
encodeURIComponent
(
this
.
getUrl
());
}
...
...
@@ -44,6 +46,7 @@ module.exports = function(req) {
}
this
.
getMastodonLink
=
function
()
{
_lqdnName
=
"
@laquadrature
"
;
return
'
https://mamot.fr/share?text=
'
+
encodeURIComponent
(
this
.
getTitle
()
+
'
'
+
this
.
getContent
()
...
...
tests/run.js
View file @
005c1457
#!/usr/bin/env nodeunit
global
.
config
=
{};
const
I18n
=
require
(
'
../i18n.js
'
);
const
ShareMessage
=
require
(
'
../shareMessage.js
'
);
const
i18n
=
new
I18n
();
exports
.
i18n
=
{
...
...
@@ -41,3 +43,33 @@ exports.i18n = {
}
}
};
exports
.
shareMessage
=
{
default
:
function
(
test
)
{
let
req
=
{
protocol
:
'
https
'
,
headers
:
{
host
:
'
localhost
'
},
i18n
:
i18n
,
args
:
{
bgColor
:
'
#f54358
'
,
fgColor
:
'
#ffd201
'
,
text
:
'
démocratie
'
,
font
:
'
lineal
'
,
icon
:
1
,
signature
:
''
}
};
let
msg
=
new
ShareMessage
(
req
);
i18n
.
setLocale
(
'
fr
'
);
test
.
strictEqual
(
msg
.
getUrl
(),
'
https://localhost/?bgColor=%23f54358&fgColor=%23ffd201&text=d%C3%A9mocratie&font=lineal&icon=1&signature=&lang=fr
'
);
test
.
strictEqual
(
msg
.
getTitle
(),
'
Soutenez @laquadrature ! #LQDoN
'
);
test
.
strictEqual
(
msg
.
getContent
(),
'
https://localhost
'
);
test
.
strictEqual
(
msg
.
getTwitterLink
(),
'
https://twitter.com/intent/tweet?text=Soutenez%20%40laquadrature%20!%20%23LQDoN%20https%3A%2F%2Flocalhost%20https%3A%2F%2Flocalhost%2F%3FbgColor%3D%2523f54358%26fgColor%3D%2523ffd201%26text%3Dd%25C3%25A9mocratie%26font%3Dlineal%26icon%3D1%26signature%3D%26lang%3Dfr
'
);
test
.
strictEqual
(
msg
.
getFacebookLink
(),
'
https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Flocalhost%2F%3FbgColor%3D%2523f54358%26fgColor%3D%2523ffd201%26text%3Dd%25C3%25A9mocratie%26font%3Dlineal%26icon%3D1%26signature%3D%26lang%3Dfr
'
);
test
.
strictEqual
(
msg
.
getDiasporaLink
(),
'
https://share.diasporafoundation.org/?title=Soutenez%20La%20Quadrature%20du%20Net%20!%20%23LQDoN%20https%3A%2F%2Flocalhost&url=https%3A%2F%2Flocalhost%2F%3FbgColor%3D%2523f54358%26fgColor%3D%2523ffd201%26text%3Dd%25C3%25A9mocratie%26font%3Dlineal%26icon%3D1%26signature%3D%26lang%3Dfr
'
);
test
.
strictEqual
(
msg
.
getMastodonLink
(),
'
https://mamot.fr/share?text=Soutenez%20%40laquadrature%20!%20%23LQDoN%20https%3A%2F%2Flocalhost%20https%3A%2F%2Flocalhost%2F%3FbgColor%3D%2523f54358%26fgColor%3D%2523ffd201%26text%3Dd%25C3%25A9mocratie%26font%3Dlineal%26icon%3D1%26signature%3D%26lang%3Dfr
'
);
test
.
done
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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