diff options
Diffstat (limited to 'server/tests/feeds/feeds.ts')
-rw-r--r-- | server/tests/feeds/feeds.ts | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 437470327..4510177cc 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
@@ -51,7 +51,7 @@ describe('Test syndication feeds', () => { | |||
51 | 51 | ||
52 | { | 52 | { |
53 | const attr = { username: 'john', password: 'password' } | 53 | const attr = { username: 'john', password: 'password' } |
54 | await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: attr.username, password: attr.password }) | 54 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password }) |
55 | userAccessToken = await userLogin(servers[0], attr) | 55 | userAccessToken = await userLogin(servers[0], attr) |
56 | 56 | ||
57 | const res = await getMyUserInformation(servers[0].url, userAccessToken) | 57 | const res = await getMyUserInformation(servers[0].url, userAccessToken) |
@@ -61,7 +61,7 @@ describe('Test syndication feeds', () => { | |||
61 | } | 61 | } |
62 | 62 | ||
63 | { | 63 | { |
64 | await uploadVideo(servers[ 0 ].url, userAccessToken, { name: 'user video' }) | 64 | await uploadVideo(servers[0].url, userAccessToken, { name: 'user video' }) |
65 | } | 65 | } |
66 | 66 | ||
67 | { | 67 | { |
@@ -70,11 +70,11 @@ describe('Test syndication feeds', () => { | |||
70 | description: 'my super description for server 1', | 70 | description: 'my super description for server 1', |
71 | fixture: 'video_short.webm' | 71 | fixture: 'video_short.webm' |
72 | } | 72 | } |
73 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes) | 73 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) |
74 | const videoId = res.body.video.id | 74 | const videoId = res.body.video.id |
75 | 75 | ||
76 | await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoId, 'super comment 1') | 76 | await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 1') |
77 | await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoId, 'super comment 2') | 77 | await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 2') |
78 | } | 78 | } |
79 | 79 | ||
80 | await waitJobs(servers) | 80 | await waitJobs(servers) |
@@ -84,18 +84,18 @@ describe('Test syndication feeds', () => { | |||
84 | 84 | ||
85 | it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () { | 85 | it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () { |
86 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { | 86 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { |
87 | const rss = await getXMLfeed(servers[ 0 ].url, feed) | 87 | const rss = await getXMLfeed(servers[0].url, feed) |
88 | expect(rss.text).xml.to.be.valid() | 88 | expect(rss.text).xml.to.be.valid() |
89 | 89 | ||
90 | const atom = await getXMLfeed(servers[ 0 ].url, feed, 'atom') | 90 | const atom = await getXMLfeed(servers[0].url, feed, 'atom') |
91 | expect(atom.text).xml.to.be.valid() | 91 | expect(atom.text).xml.to.be.valid() |
92 | } | 92 | } |
93 | }) | 93 | }) |
94 | 94 | ||
95 | it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () { | 95 | it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () { |
96 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { | 96 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { |
97 | const json = await getJSONfeed(servers[ 0 ].url, feed) | 97 | const json = await getJSONfeed(servers[0].url, feed) |
98 | expect(JSON.parse(json.text)).to.be.jsonSchema({ 'type': 'object' }) | 98 | expect(JSON.parse(json.text)).to.be.jsonSchema({ type: 'object' }) |
99 | } | 99 | } |
100 | }) | 100 | }) |
101 | }) | 101 | }) |
@@ -118,11 +118,11 @@ describe('Test syndication feeds', () => { | |||
118 | const json = await getJSONfeed(server.url, 'videos') | 118 | const json = await getJSONfeed(server.url, 'videos') |
119 | const jsonObj = JSON.parse(json.text) | 119 | const jsonObj = JSON.parse(json.text) |
120 | expect(jsonObj.items.length).to.be.equal(2) | 120 | expect(jsonObj.items.length).to.be.equal(2) |
121 | expect(jsonObj.items[ 0 ].attachments).to.exist | 121 | expect(jsonObj.items[0].attachments).to.exist |
122 | expect(jsonObj.items[ 0 ].attachments.length).to.be.eq(1) | 122 | expect(jsonObj.items[0].attachments.length).to.be.eq(1) |
123 | expect(jsonObj.items[ 0 ].attachments[ 0 ].mime_type).to.be.eq('application/x-bittorrent') | 123 | expect(jsonObj.items[0].attachments[0].mime_type).to.be.eq('application/x-bittorrent') |
124 | expect(jsonObj.items[ 0 ].attachments[ 0 ].size_in_bytes).to.be.eq(218910) | 124 | expect(jsonObj.items[0].attachments[0].size_in_bytes).to.be.eq(218910) |
125 | expect(jsonObj.items[ 0 ].attachments[ 0 ].url).to.contain('720.torrent') | 125 | expect(jsonObj.items[0].attachments[0].url).to.contain('720.torrent') |
126 | } | 126 | } |
127 | }) | 127 | }) |
128 | 128 | ||
@@ -131,16 +131,16 @@ describe('Test syndication feeds', () => { | |||
131 | const json = await getJSONfeed(servers[0].url, 'videos', { accountId: rootAccountId }) | 131 | const json = await getJSONfeed(servers[0].url, 'videos', { accountId: rootAccountId }) |
132 | const jsonObj = JSON.parse(json.text) | 132 | const jsonObj = JSON.parse(json.text) |
133 | expect(jsonObj.items.length).to.be.equal(1) | 133 | expect(jsonObj.items.length).to.be.equal(1) |
134 | expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') | 134 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
135 | expect(jsonObj.items[ 0 ].author.name).to.equal('root') | 135 | expect(jsonObj.items[0].author.name).to.equal('root') |
136 | } | 136 | } |
137 | 137 | ||
138 | { | 138 | { |
139 | const json = await getJSONfeed(servers[0].url, 'videos', { accountId: userAccountId }) | 139 | const json = await getJSONfeed(servers[0].url, 'videos', { accountId: userAccountId }) |
140 | const jsonObj = JSON.parse(json.text) | 140 | const jsonObj = JSON.parse(json.text) |
141 | expect(jsonObj.items.length).to.be.equal(1) | 141 | expect(jsonObj.items.length).to.be.equal(1) |
142 | expect(jsonObj.items[ 0 ].title).to.equal('user video') | 142 | expect(jsonObj.items[0].title).to.equal('user video') |
143 | expect(jsonObj.items[ 0 ].author.name).to.equal('john') | 143 | expect(jsonObj.items[0].author.name).to.equal('john') |
144 | } | 144 | } |
145 | 145 | ||
146 | for (const server of servers) { | 146 | for (const server of servers) { |
@@ -148,14 +148,14 @@ describe('Test syndication feeds', () => { | |||
148 | const json = await getJSONfeed(server.url, 'videos', { accountName: 'root@localhost:' + servers[0].port }) | 148 | const json = await getJSONfeed(server.url, 'videos', { accountName: 'root@localhost:' + servers[0].port }) |
149 | const jsonObj = JSON.parse(json.text) | 149 | const jsonObj = JSON.parse(json.text) |
150 | expect(jsonObj.items.length).to.be.equal(1) | 150 | expect(jsonObj.items.length).to.be.equal(1) |
151 | expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') | 151 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
152 | } | 152 | } |
153 | 153 | ||
154 | { | 154 | { |
155 | const json = await getJSONfeed(server.url, 'videos', { accountName: 'john@localhost:' + servers[0].port }) | 155 | const json = await getJSONfeed(server.url, 'videos', { accountName: 'john@localhost:' + servers[0].port }) |
156 | const jsonObj = JSON.parse(json.text) | 156 | const jsonObj = JSON.parse(json.text) |
157 | expect(jsonObj.items.length).to.be.equal(1) | 157 | expect(jsonObj.items.length).to.be.equal(1) |
158 | expect(jsonObj.items[ 0 ].title).to.equal('user video') | 158 | expect(jsonObj.items[0].title).to.equal('user video') |
159 | } | 159 | } |
160 | } | 160 | } |
161 | }) | 161 | }) |
@@ -165,16 +165,16 @@ describe('Test syndication feeds', () => { | |||
165 | const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: rootChannelId }) | 165 | const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: rootChannelId }) |
166 | const jsonObj = JSON.parse(json.text) | 166 | const jsonObj = JSON.parse(json.text) |
167 | expect(jsonObj.items.length).to.be.equal(1) | 167 | expect(jsonObj.items.length).to.be.equal(1) |
168 | expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') | 168 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
169 | expect(jsonObj.items[ 0 ].author.name).to.equal('root') | 169 | expect(jsonObj.items[0].author.name).to.equal('root') |
170 | } | 170 | } |
171 | 171 | ||
172 | { | 172 | { |
173 | const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: userChannelId }) | 173 | const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: userChannelId }) |
174 | const jsonObj = JSON.parse(json.text) | 174 | const jsonObj = JSON.parse(json.text) |
175 | expect(jsonObj.items.length).to.be.equal(1) | 175 | expect(jsonObj.items.length).to.be.equal(1) |
176 | expect(jsonObj.items[ 0 ].title).to.equal('user video') | 176 | expect(jsonObj.items[0].title).to.equal('user video') |
177 | expect(jsonObj.items[ 0 ].author.name).to.equal('john') | 177 | expect(jsonObj.items[0].author.name).to.equal('john') |
178 | } | 178 | } |
179 | 179 | ||
180 | for (const server of servers) { | 180 | for (const server of servers) { |
@@ -182,14 +182,14 @@ describe('Test syndication feeds', () => { | |||
182 | const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'root_channel@localhost:' + servers[0].port }) | 182 | const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'root_channel@localhost:' + servers[0].port }) |
183 | const jsonObj = JSON.parse(json.text) | 183 | const jsonObj = JSON.parse(json.text) |
184 | expect(jsonObj.items.length).to.be.equal(1) | 184 | expect(jsonObj.items.length).to.be.equal(1) |
185 | expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') | 185 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
186 | } | 186 | } |
187 | 187 | ||
188 | { | 188 | { |
189 | const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'john_channel@localhost:' + servers[0].port }) | 189 | const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'john_channel@localhost:' + servers[0].port }) |
190 | const jsonObj = JSON.parse(json.text) | 190 | const jsonObj = JSON.parse(json.text) |
191 | expect(jsonObj.items.length).to.be.equal(1) | 191 | expect(jsonObj.items.length).to.be.equal(1) |
192 | expect(jsonObj.items[ 0 ].title).to.equal('user video') | 192 | expect(jsonObj.items[0].title).to.equal('user video') |
193 | } | 193 | } |
194 | } | 194 | } |
195 | }) | 195 | }) |
@@ -202,8 +202,8 @@ describe('Test syndication feeds', () => { | |||
202 | 202 | ||
203 | const jsonObj = JSON.parse(json.text) | 203 | const jsonObj = JSON.parse(json.text) |
204 | expect(jsonObj.items.length).to.be.equal(2) | 204 | expect(jsonObj.items.length).to.be.equal(2) |
205 | expect(jsonObj.items[ 0 ].html_content).to.equal('super comment 2') | 205 | expect(jsonObj.items[0].html_content).to.equal('super comment 2') |
206 | expect(jsonObj.items[ 1 ].html_content).to.equal('super comment 1') | 206 | expect(jsonObj.items[1].html_content).to.equal('super comment 1') |
207 | } | 207 | } |
208 | }) | 208 | }) |
209 | }) | 209 | }) |