mirror of
https://github.com/snobu/destreamer.git
synced 2026-01-16 21:12:13 +00:00
Sync tokencache and dev branches
This commit is contained in:
41
test/test.ts
41
test/test.ts
@@ -1,5 +1,8 @@
|
||||
import { getVideoUrls } from '../utils';
|
||||
import puppeteer from 'puppeteer';
|
||||
import assert from 'assert';
|
||||
import tmp from 'tmp';
|
||||
import fs from 'fs';
|
||||
|
||||
let browser: any;
|
||||
let page: any;
|
||||
@@ -23,4 +26,42 @@ describe('Puppeteer', () => {
|
||||
|
||||
after(async () => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
|
||||
describe('Destreamer', () => {
|
||||
it('should parse and sanitize URL list from file', () => {
|
||||
const testIn: string[] = [
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd",
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?",
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd&",
|
||||
"",
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?a=b&c",
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?a",
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddd",
|
||||
"https://web.microsoftstream.com/video/xxxxxx-zzzz-hhhh-rrrr-dddddddddddd",
|
||||
""
|
||||
];
|
||||
const expectedOut: string[] = [
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd",
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd",
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?a=b&c",
|
||||
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?a"
|
||||
];
|
||||
const tmpFile = tmp.fileSync({ postfix: '.txt' });
|
||||
let testOut: string[];
|
||||
|
||||
fs.writeFileSync(tmpFile.fd, testIn.join('\r\n'));
|
||||
|
||||
testOut = getVideoUrls([tmpFile.name]);
|
||||
if (testOut.length !== expectedOut.length)
|
||||
assert.strictEqual(testOut, expectedOut, "URL list not sanitized");
|
||||
|
||||
for (let i=0, l=testOut.length; i<l; ++i) {
|
||||
if (testOut[i] !== expectedOut[i])
|
||||
assert.strictEqual(testOut[i], expectedOut[i], "URL not sanitized");
|
||||
}
|
||||
|
||||
assert.ok("sanitizeUrls ok");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user