1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
11 setAccessTokensToServers,
13 } from '../../../../shared/extra-utils/index'
14 import { flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
16 const expect = chai.expect
18 describe('Test services', function () {
19 let server: ServerInfo = null
21 before(async function () {
24 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ])
28 const videoAttributes = {
31 await uploadVideo(server.url, server.accessToken, videoAttributes)
33 const res = await getVideosList(server.url)
34 server.video = res.body.data[0]
37 it('Should have a valid oEmbed response', async function () {
38 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
40 const res = await getOEmbed(server.url, oembedUrl)
41 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
42 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
43 'frameborder="0" allowfullscreen></iframe>'
44 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg'
46 expect(res.body.html).to.equal(expectedHtml)
47 expect(res.body.title).to.equal(server.video.name)
48 expect(res.body.author_name).to.equal(server.video.account.name)
49 expect(res.body.width).to.equal(560)
50 expect(res.body.height).to.equal(315)
51 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
52 expect(res.body.thumbnail_width).to.equal(560)
53 expect(res.body.thumbnail_height).to.equal(315)
56 it('Should have a valid oEmbed response with small max height query', async function () {
57 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
62 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
63 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
64 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
65 'frameborder="0" allowfullscreen></iframe>'
67 expect(res.body.html).to.equal(expectedHtml)
68 expect(res.body.title).to.equal(server.video.name)
69 expect(res.body.author_name).to.equal(server.video.account.name)
70 expect(res.body.height).to.equal(50)
71 expect(res.body.width).to.equal(50)
72 expect(res.body).to.not.have.property('thumbnail_url')
73 expect(res.body).to.not.have.property('thumbnail_width')
74 expect(res.body).to.not.have.property('thumbnail_height')
78 killallServers([ server ])