/
oembed.js
60 lines (48 loc) · 1.53 KB
/
oembed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const t = require('../test-lib/test.js');
const assert = require('assert');
describe('Oembed', function() {
this.timeout(t.timeout);
let apos;
after(function () {
return t.destroy(apos);
});
/// ///
// EXISTENCE
/// ///
it('should initialize', async function() {
apos = await t.create({
root: module
});
assert(apos.modules['@apostrophecms/oembed']);
assert(apos.oembed.__meta.name === '@apostrophecms/oembed');
});
// TODO: test this with mocks. Travis CI erratically times out
// when we test against real YouTube, which produces false
// failures that lead us to ignore CI results.
//
// let youtube = 'https://www.youtube.com/watch?v=us00G8oILCM&feature=related';
// it('YouTube still has the video we like to use for testing', async function() {
// try {
// const response = await request({
// method: 'GET',
// uri: youtube,
// resolveWithFullResponse: true
// });
// assert(response.statusCode === 200);
// } catch (e) {
// assert(false);
// }
// });
// it('Should deliver an oembed response for YouTube', async function() {
// const queryString = qs.stringify({ url: youtube });
// const uri = `/modules/@apostrophecms/oembed/query?${queryString}`;
// const response = await request({
// uri,
// method: 'GET',
// resolveWithFullResponse: true
// });
// assert(response.statusCode === 200);
// const data = JSON.parse(response.body);
// assert(data.type === 'video');
// });
});