Add tests missed in last commit

This commit is contained in:
Calvin Montgomery 2017-01-05 21:04:15 -08:00
parent e2abb90d14
commit 6e61a13354
2 changed files with 37 additions and 0 deletions

21
test/customembed.js Normal file
View file

@ -0,0 +1,21 @@
const customembed = require('../lib/customembed');
const assert = require('assert');
describe('customembed', () => {
describe('#filter', () => {
it('rejects plain-HTTP <embed> inputs', () => {
const input = '<embed src="http://foo.bar/baz.swf" type="application/x-shockwave-flash"></embed>';
assert.throws(() => { customembed.filter(input) }, /must be HTTPS/);
});
it('rejects plain-HTTP <object> inputs', () => {
const input = '<object data="http://foo.bar/baz.swf" type="application/x-shockwave-flash"></object>';
assert.throws(() => { customembed.filter(input) }, /must be HTTPS/);
});
it('rejects plain-HTTP <iframe> inputs', () => {
const input = '<iframe src="http://foo.bar/baz.swf"></iframe>';
assert.throws(() => { customembed.filter(input) }, /must be HTTPS/);
});
});
});

16
test/ffmpeg.js Normal file
View file

@ -0,0 +1,16 @@
const assert = require('assert');
const ffmpeg = require('../lib/ffmpeg');
const Config = require('../lib/config');
describe('ffmpeg', () => {
describe('#query', () => {
it('rejects plain http links', done => {
Config.set('ffmpeg.enabled', true);
ffmpeg.query('http://foo.bar/baz.mp4', err => {
assert(/begins with 'https:/.test(err),
`Expected error due to plain HTTP but got "${err}"`);
done();
});
});
});
});