Gitter migration: Point people to app.gitter.im (rollout pt. 1)
[gitter.git] / public / js / utils / social-test.js
blob8af0cf3a9d1c009eb32cfa5df783f4c2172b9b92
1 'use strict';
3 var social = require('./social');
4 var assert = require('assert');
6 describe('social', function() {
7   it('generates a twitter share url', function() {
8     var url = social.generateTwitterShareUrl('owner/room');
9     assert.equal(
10       url,
11       'https://twitter.com/share?text=Join%20the%20chat%20room%20on%20Gitter%20for%20owner%2Froom%3A&url=https://gitter.im/owner/room&related=gitchat&via=gitchat'
12     );
13   });
15   it('throws if it cant generate a twitter share url', function() {
16     var expected;
17     try {
18       social.generateTwitterShareUrl();
19     } catch (e) {
20       expected = e;
21     }
23     assert(expected, 'error expected');
24   });
26   it('generates a facebook share url', function() {
27     var url = social.generateFacebookShareUrl('owner/room');
28     assert.equal(url, 'http://www.facebook.com/sharer/sharer.php?u=https://gitter.im/owner/room');
29   });
31   it('throws if it cant generate a facebook share url', function() {
32     var expected;
33     try {
34       social.generateFacebookShareUrl();
35     } catch (e) {
36       expected = e;
37     }
39     assert(expected, 'error expected');
40   });
42   it('generates a linkedin share url', function() {
43     var url = social.generateLinkedinShareUrl('owner/room');
44     assert.equal(
45       url,
46       'https://www.linkedin.com/shareArticle?mini=true&url=https://gitter.im/owner/room&title=owner%2Froom%20on%20Gitter&summary=Join%20the%20chat%20room%20on%20Gitter%20for%20owner%2Froom&source=Gitter'
47     );
48   });
50   it('throws if it cant generate a linkedin share url', function() {
51     var expected;
52     try {
53       social.generateLinkedinShareUrl();
54     } catch (e) {
55       expected = e;
56     }
58     assert(expected, 'error expected');
59   });
61   it('generates a google plus share url', function() {
62     var url = social.generateGooglePlusShareUrl('owner/room');
63     assert.equal(url, 'https://plus.google.com/share?url=https://gitter.im/owner/room');
64   });
66   it('throws if it cant generate a google plus share url', function() {
67     var expected;
68     try {
69       social.generateGooglePlusShareUrl();
70     } catch (e) {
71       expected = e;
72     }
74     assert(expected, 'error expected');
75   });
76 });