UNPKG

1.93 kBJavaScriptView Raw
1
2var t = require('../test-lib/test.js');
3var assert = require('assert');
4var apos;
5
6describe('Oembed', function() {
7
8 this.timeout(t.timeout);
9
10 after(function(done) {
11 return t.destroy(apos, done);
12 });
13
14 /// ///
15 // EXISTENCE
16 /// ///
17
18 it('should initialize', function(done) {
19 apos = require('../index.js')({
20 root: module,
21 shortName: 'test',
22
23 modules: {
24 'apostrophe-express': {
25 secret: 'xxx',
26 port: 7900,
27 csrf: false
28 }
29 },
30 afterInit: function(callback) {
31 assert(apos.modules['apostrophe-oembed']);
32 assert(apos.oembed);
33 // In tests this will be the name of the test file,
34 // so override that in order to get apostrophe to
35 // listen normally and not try to run a task. -Tom
36 apos.argv._ = [];
37 return callback(null);
38 },
39 afterListen: function(err) {
40 assert(!err);
41 done();
42 }
43 });
44 });
45
46 // TODO: test this with mocks. Travis CI erratically times out
47 // when we test against real YouTube, which produces false
48 // failures that lead us to ignore CI results.
49 //
50 // var youtube = 'https://www.youtube.com/watch?v=us00G8oILCM&feature=related';
51
52 // it('YouTube still has the video we like to use for testing', function(done) {
53 // return request(youtube, function(err, response, body) {
54 // assert(!err);
55 // assert(response.statusCode === 200);
56 // return done();
57 // });
58 // });
59
60 // it('Should deliver an oembed response for YouTube', function(done) {
61 // return request('http://localhost:7900/modules/apostrophe-oembed/query?' + qs.stringify(
62 // {
63 // url: youtube
64 // }), function(err, response, body) {
65 // assert(!err);
66 // assert(response.statusCode === 200);
67 // var data = JSON.parse(body);
68 // assert(data.type === 'video');
69 // return done();
70 // });
71 // });
72
73});