1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
5 import { flushTests, getOEmbed, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index'
6 import { runServer } from '../../utils/server/servers'
8 const expect = chai.expect
10 describe('Test services', function () {
11 let server: ServerInfo = null
13 before(async function () {
18 server = await runServer(1)
20 await setAccessTokensToServers([ server ])
22 const videoAttributes = {
25 await uploadVideo(server.url, server.accessToken, videoAttributes)
27 const res = await getVideosList(server.url)
28 server.video = res.body.data[0]
31 it('Should have a valid oEmbed response', async function () {
32 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
34 const res = await getOEmbed(server.url, oembedUrl)
35 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
36 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
37 'frameborder="0" allowfullscreen></iframe>'
38 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg'
40 expect(res.body.html).to.equal(expectedHtml)
41 expect(res.body.title).to.equal(server.video.name)
42 expect(res.body.author_name).to.equal(server.video.account.name)
43 expect(res.body.width).to.equal(560)
44 expect(res.body.height).to.equal(315)
45 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
46 expect(res.body.thumbnail_width).to.equal(560)
47 expect(res.body.thumbnail_height).to.equal(315)
50 it('Should have a valid oEmbed response with small max height query', async function () {
51 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
56 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
57 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
58 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
59 'frameborder="0" allowfullscreen></iframe>'
61 expect(res.body.html).to.equal(expectedHtml)
62 expect(res.body.title).to.equal(server.video.name)
63 expect(res.body.author_name).to.equal(server.video.account.name)
64 expect(res.body.height).to.equal(50)
65 expect(res.body.width).to.equal(50)
66 expect(res.body).to.not.have.property('thumbnail_url')
67 expect(res.body).to.not.have.property('thumbnail_width')
68 expect(res.body).to.not.have.property('thumbnail_height')
71 after(async function () {
72 killallServers([ server ])