From 78038b950513bece2c5e460e1633349f4fc683ec Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 30 Apr 2023 05:17:50 +0300 Subject: [PATCH] Create format.test.js --- tests/commands/playlist/format.test.js | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/commands/playlist/format.test.js diff --git a/tests/commands/playlist/format.test.js b/tests/commands/playlist/format.test.js new file mode 100644 index 0000000000..0d048732aa --- /dev/null +++ b/tests/commands/playlist/format.test.js @@ -0,0 +1,32 @@ +const { execSync } = require('child_process') +const fs = require('fs-extra') +const path = require('path') +const glob = require('glob') + +beforeEach(() => { + fs.emptyDirSync('tests/__data__/output') + fs.copyFileSync( + 'tests/__data__/input/database/playlist_format.streams.db', + 'tests/__data__/output/streams.db' + ) + + const stdout = execSync('DB_DIR=tests/__data__/output npm run playlist:format', { + encoding: 'utf8' + }) +}) + +it('can format playlists', () => { + const files = glob + .sync('tests/__data__/expected/streams/*.m3u') + .map(f => f.replace('tests/__data__/expected/', '')) + + files.forEach(filepath => { + expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`)) + }) +}) + +function content(filepath) { + return fs.readFileSync(`tests/__data__/${filepath}`, { + encoding: 'utf8' + }) +}