2014-08-02 17:46:19 +02:00
|
|
|
/* plugins go here */
|
|
|
|
|
|
|
|
var msg = function(msg) {
|
2014-08-09 14:54:18 +02:00
|
|
|
return {'text': msg };
|
|
|
|
};
|
2014-08-02 17:46:19 +02:00
|
|
|
|
|
|
|
var metadata_name = function(message) {
|
2014-08-09 14:54:18 +02:00
|
|
|
if (message.metadata && message.metadata[0] && message.metadata[0].name) {
|
|
|
|
return message.metadata[0].name;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
};
|
2014-08-02 17:46:19 +02:00
|
|
|
|
2014-08-03 05:48:09 +02:00
|
|
|
var expectTheseMessagesToContain = function(urls, pluginType, plugins) {
|
|
|
|
for (var i = 0; i < urls.length; i++) {
|
|
|
|
expect(
|
|
|
|
metadata_name(
|
|
|
|
plugins.PluginManager.contentForMessage(msg(urls[i]))
|
|
|
|
)
|
|
|
|
).toEqual(pluginType);
|
|
|
|
}
|
2014-08-09 14:54:18 +02:00
|
|
|
};
|
2014-08-03 05:48:09 +02:00
|
|
|
|
2014-08-02 17:46:19 +02:00
|
|
|
describe('filter', function() {
|
|
|
|
beforeEach(module('plugins'));
|
|
|
|
|
|
|
|
describe('Plugins', function() {
|
|
|
|
beforeEach(module(function($provide) {
|
|
|
|
$provide.value('version', 'TEST_VER');
|
|
|
|
}));
|
|
|
|
|
2014-08-03 05:48:09 +02:00
|
|
|
it('should recognize spotify tracks', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
2014-08-09 15:06:34 +02:00
|
|
|
'spotify:track:6JEK0CvvjDjjMUBFoXShNZ',
|
|
|
|
'https://open.spotify.com/track/6JEK0CvvjDjjMUBFoXShNZ'
|
2014-08-03 05:48:09 +02:00
|
|
|
],
|
|
|
|
'Spotify track',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
2014-08-02 17:46:19 +02:00
|
|
|
|
|
|
|
it('should recognize youtube videos', inject(function(plugins) {
|
2014-08-03 05:48:09 +02:00
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
|
|
|
|
'http://www.youtube.com/watch?v=dQw4w9WgXcQ',
|
|
|
|
'http://youtu.be/J6vIS8jb6Fs',
|
|
|
|
'https://youtu.be/J6vIS8jb6Fs',
|
2014-08-09 15:06:34 +02:00
|
|
|
'http://www.youtube.com/embed/dQw4w9WgXcQ',
|
|
|
|
'https://www.youtube.com/embed/dQw4w9WgXcQ',
|
|
|
|
'youtu.be/dQw4w9WgXcQ'
|
2014-08-03 05:48:09 +02:00
|
|
|
],
|
|
|
|
'YouTube video',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should recognize dailymotion videos', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'dailymotion.com/video/test',
|
|
|
|
'dailymotion.com/video/#video=asdf',
|
|
|
|
'dai.ly/sfg'
|
|
|
|
],
|
|
|
|
'Dailymotion video',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should recognize allocine videos', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'allocine.fr/videokast/video-12',
|
|
|
|
'allocine.fr/cmedia=234'
|
|
|
|
],
|
|
|
|
'AlloCine video',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should recognize images', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
2014-08-09 15:06:34 +02:00
|
|
|
'http://i.imgur.com/BTNIDBR.gif',
|
|
|
|
'https://i.imgur.com/1LmDmct.jpg',
|
|
|
|
'http://i.imgur.com/r4FKrnu.jpeg',
|
|
|
|
'https://4z2.de/gb-mobile-new.png',
|
|
|
|
'http://static.weechat.org/images/screenshots/relay/medium/glowing-bear.png',
|
2014-08-18 17:43:55 +02:00
|
|
|
'http://foo.bar/baz.php?img=trololo.png&dummy=yes',
|
2015-01-14 16:36:03 +01:00
|
|
|
'https://tro.lo.lo/images/rick.png?size=123x45',
|
|
|
|
'https://pbs.twimg.com/media/B66rbCuIMAAxiFF.jpg:large',
|
|
|
|
'https://pbs.twimg.com/media/B6OZuCYCEAEV8SA.jpg:medium'
|
2014-08-03 05:48:09 +02:00
|
|
|
],
|
|
|
|
'image',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should recognize cloud music', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'http://soundcloud.com/',
|
|
|
|
'https://sadf.mixcloud.com/',
|
|
|
|
],
|
|
|
|
'cloud music',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should recognize google map', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'https://www.google.com/maps/@48.0034139,-74.9129088,6z',
|
|
|
|
],
|
|
|
|
'Google Map',
|
|
|
|
plugins);
|
2014-08-02 17:46:19 +02:00
|
|
|
}));
|
2014-08-03 05:48:09 +02:00
|
|
|
|
|
|
|
it('should recognize google map', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'https://asciinema.org/a/10625',
|
|
|
|
],
|
|
|
|
'ascii cast',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should recognize meteograms', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'http://www.yr.no/sted/Canada/Quebec/Montreal/',
|
|
|
|
],
|
|
|
|
'meteogram',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
2014-08-09 15:41:55 +02:00
|
|
|
it('should recognize gists', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'https://gist.github.com/lorenzhs/e8c1a7d56fa170320eb8',
|
|
|
|
'https://gist.github.com/e8c1a7d56fa170320eb8',
|
|
|
|
],
|
|
|
|
'Gist',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should recognize tweets', inject(function(plugins) {
|
|
|
|
expectTheseMessagesToContain([
|
|
|
|
'https://twitter.com/DFB_Team_EN/statuses/488436782959448065',
|
|
|
|
],
|
|
|
|
'Tweet',
|
|
|
|
plugins);
|
|
|
|
}));
|
|
|
|
|
2014-08-02 17:46:19 +02:00
|
|
|
});
|
|
|
|
});
|