2
2
// const testUtils = require('./utils');
3
3
require ( './utils' ) ;
4
4
5
+ const should = require ( 'should' ) ;
5
6
const social = require ( '../lib/index' ) ;
6
7
7
8
describe ( 'lib/social: urls' , function ( ) {
9
+ // Verify each platform has a URL function
8
10
it ( 'should have a twitter url function' , function ( ) {
9
11
should . exist ( social . twitter ) ;
10
12
} ) ;
@@ -13,13 +15,41 @@ describe('lib/social: urls', function () {
13
15
should . exist ( social . facebook ) ;
14
16
} ) ;
15
17
18
+ it ( 'should have a threads url function' , function ( ) {
19
+ should . exist ( social . threads ) ;
20
+ } ) ;
21
+
22
+ it ( 'should have a bluesky url function' , function ( ) {
23
+ should . exist ( social . bluesky ) ;
24
+ } ) ;
25
+
26
+ it ( 'should have a mastodon url function' , function ( ) {
27
+ should . exist ( social . mastodon ) ;
28
+ } ) ;
29
+
30
+ it ( 'should have a tiktok url function' , function ( ) {
31
+ should . exist ( social . tiktok ) ;
32
+ } ) ;
33
+
34
+ it ( 'should have a youtube url function' , function ( ) {
35
+ should . exist ( social . youtube ) ;
36
+ } ) ;
37
+
38
+ it ( 'should have an instagram url function' , function ( ) {
39
+ should . exist ( social . instagram ) ;
40
+ } ) ;
41
+
42
+ it ( 'should have a linkedin url function' , function ( ) {
43
+ should . exist ( social . linkedin ) ;
44
+ } ) ;
45
+
16
46
describe ( 'twitter' , function ( ) {
17
47
it ( 'should return a correct concatenated URL' , function ( ) {
18
- social . twitter ( 'myusername' ) . should . eql ( 'https://twitter .com/myusername' ) ;
48
+ social . twitter ( '@ myusername' ) . should . eql ( 'https://x .com/myusername' ) ;
19
49
} ) ;
20
50
21
51
it ( 'should return a url without an @ sign if one is provided' , function ( ) {
22
- social . twitter ( '@ myusername' ) . should . eql ( 'https://twitter .com/myusername' ) ;
52
+ social . twitter ( 'myusername' ) . should . eql ( 'https://x .com/myusername' ) ;
23
53
} ) ;
24
54
} ) ;
25
55
@@ -36,4 +66,86 @@ describe('lib/social: urls', function () {
36
66
social . facebook ( '/page/xxx/123' ) . should . eql ( 'https://www.facebook.com/page/xxx/123' ) ;
37
67
} ) ;
38
68
} ) ;
69
+
70
+ describe ( 'threads' , function ( ) {
71
+ it ( 'should return a correct concatenated URL' , function ( ) {
72
+ social . threads ( '@myusername' ) . should . eql ( 'https://www.threads.net/@myusername' ) ;
73
+ } ) ;
74
+
75
+ it ( 'should return a correct URL for usernames without @' , function ( ) {
76
+ social . threads ( 'myusername' ) . should . eql ( 'https://www.threads.net/@myusername' ) ;
77
+ } ) ;
78
+ } ) ;
79
+
80
+ describe ( 'bluesky' , function ( ) {
81
+ it ( 'should return a correct concatenated URL' , function ( ) {
82
+ social . bluesky ( 'myusername' ) . should . eql ( 'https://bsky.app/profile/myusername' ) ;
83
+ } ) ;
84
+
85
+ it ( 'should handle domain-based usernames' , function ( ) {
86
+ social . bluesky ( 'user.domain.com' ) . should . eql ( 'https://bsky.app/profile/user.domain.com' ) ;
87
+ } ) ;
88
+ } ) ;
89
+
90
+ describe ( 'mastodon' , function ( ) {
91
+ it ( 'should return a correct concatenated URL for instance-specific handle' , function ( ) {
92
+ social . mastodon ( 'mastodon.social/@myusername' ) . should . eql ( 'https://mastodon.social/@myusername' ) ;
93
+ } ) ;
94
+
95
+ it ( 'should return a correct concatenated URL for federated handle' , function ( ) {
96
+ social . mastodon ( 'mastodon.social/@[email protected] ' ) . should . eql ( 'https://mastodon.social/@[email protected] ' ) ;
97
+ } ) ;
98
+
99
+ it ( 'should handle subdomains in instance URLs' , function ( ) {
100
+ social . mastodon ( 'eu.mastodon.green/@eco' ) . should . eql ( 'https://eu.mastodon.green/@eco' ) ;
101
+ } ) ;
102
+ } ) ;
103
+
104
+ describe ( 'tiktok' , function ( ) {
105
+ it ( 'should return a correct concatenated URL' , function ( ) {
106
+ social . tiktok ( '@myusername' ) . should . eql ( 'https://www.tiktok.com/@myusername' ) ;
107
+ } ) ;
108
+
109
+ it ( 'should return a correct URL for usernames without @' , function ( ) {
110
+ social . tiktok ( 'myusername' ) . should . eql ( 'https://www.tiktok.com/@myusername' ) ;
111
+ } ) ;
112
+
113
+ it ( 'should handle usernames with periods and underscores' , function ( ) {
114
+ social . tiktok ( '@john.smith_123' ) . should . eql ( 'https://www.tiktok.com/@john.smith_123' ) ;
115
+ } ) ;
116
+ } ) ;
117
+
118
+ describe ( 'youtube' , function ( ) {
119
+ it ( 'should return a correct concatenated URL for handle-based username' , function ( ) {
120
+ social . youtube ( '@myusername' ) . should . eql ( 'https://www.youtube.com/@myusername' ) ;
121
+ } ) ;
122
+
123
+ it ( 'should return a correct concatenated URL for legacy user-based username' , function ( ) {
124
+ social . youtube ( 'user/myusername' ) . should . eql ( 'https://www.youtube.com/user/myusername' ) ;
125
+ } ) ;
126
+
127
+ it ( 'should return a correct concatenated URL for channel ID' , function ( ) {
128
+ social . youtube ( 'channel/UC4QobU6STFB0P71PMvOGN5A' ) . should . eql ( 'https://www.youtube.com/channel/UC4QobU6STFB0P71PMvOGN5A' ) ;
129
+ } ) ;
130
+ } ) ;
131
+
132
+ describe ( 'instagram' , function ( ) {
133
+ it ( 'should return a correct concatenated URL' , function ( ) {
134
+ social . instagram ( 'myusername' ) . should . eql ( 'https://www.instagram.com/myusername' ) ;
135
+ } ) ;
136
+
137
+ it ( 'should handle usernames with periods and underscores' , function ( ) {
138
+ social . instagram ( 'john.smith_123' ) . should . eql ( 'https://www.instagram.com/john.smith_123' ) ;
139
+ } ) ;
140
+ } ) ;
141
+
142
+ describe ( 'linkedin' , function ( ) {
143
+ it ( 'should return a correct concatenated URL' , function ( ) {
144
+ social . linkedin ( 'myusername' ) . should . eql ( 'https://www.linkedin.com/in/myusername' ) ;
145
+ } ) ;
146
+
147
+ it ( 'should handle usernames with periods, hyphens, and underscores' , function ( ) {
148
+ social . linkedin ( 'john.smith-123' ) . should . eql ( 'https://www.linkedin.com/in/john.smith-123' ) ;
149
+ } ) ;
150
+ } ) ;
39
151
} ) ;
0 commit comments