1 /* tslint:disable:no-unused-expression */
4 import * as chai from 'chai'
5 const expect = chai.expect
12 setAccessTokensToServers,
15 } from '../../utils/index'
16 import { runServer } from '../../utils/server/servers'
18 describe('Test services', function () {
19 let server: ServerInfo = null
21 before(async function () {
26 server = await runServer(1)
28 await setAccessTokensToServers([ server ])
30 const videoAttributes = {
33 const res = await uploadVideo(server.url, server.accessToken, videoAttributes)
34 server.video = res.body.video
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" src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
42 'frameborder="0" allowfullscreen></iframe>'
43 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg'
45 expect(res.body.html).to.equal(expectedHtml)
46 expect(res.body.title).to.equal(server.video.name)
47 expect(res.body.author_name).to.equal(server.video.accountName)
48 expect(res.body.width).to.equal(560)
49 expect(res.body.height).to.equal(315)
50 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
51 expect(res.body.thumbnail_width).to.equal(560)
52 expect(res.body.thumbnail_height).to.equal(315)
55 it('Should have a valid oEmbed response with small max height query', async function () {
56 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
61 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
62 const expectedHtml = `<iframe width="50" height="50" src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
63 'frameborder="0" allowfullscreen></iframe>'
65 expect(res.body.html).to.equal(expectedHtml)
66 expect(res.body.title).to.equal(server.video.name)
67 expect(res.body.author_name).to.equal(server.video.accountName)
68 expect(res.body.height).to.equal(50)
69 expect(res.body.width).to.equal(50)
70 expect(res.body).to.not.have.property('thumbnail_url')
71 expect(res.body).to.not.have.property('thumbnail_width')
72 expect(res.body).to.not.have.property('thumbnail_height')
75 after(async function () {
76 killallServers([ server ])
78 // Keep the logs if the test failed