diff --git a/tests/commands/api/generate.test.ts b/tests/commands/api/generate.test.ts index 86e34ce08..7f8f68aa9 100644 --- a/tests/commands/api/generate.test.ts +++ b/tests/commands/api/generate.test.ts @@ -3,15 +3,17 @@ import fs from 'fs-extra' beforeEach(() => { fs.emptyDirSync('tests/__data__/output') +}) +it('can create streams.json', () => { execSync( - 'STREAMS_DIR=tests/__data__/input/streams_generate API_DIR=tests/__data__/output/.api npm run api:generate', + 'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/api_generate API_DIR=tests/__data__/output/.api npm run api:generate', { encoding: 'utf8' } ) -}) -it('can create streams.json', () => { - expect(content('output/.api/streams.json')).toMatchObject(content('expected/.api/streams.json')) + expect(content('output/.api/streams.json')).toMatchObject( + content('expected/api_generate/.api/streams.json') + ) }) function content(filepath: string) { diff --git a/tests/commands/playlist/format.test.ts b/tests/commands/playlist/format.test.ts index 6a9fbafc5..d513c8b38 100644 --- a/tests/commands/playlist/format.test.ts +++ b/tests/commands/playlist/format.test.ts @@ -4,7 +4,7 @@ import { glob } from 'glob' beforeEach(() => { fs.emptyDirSync('tests/__data__/output') - fs.copySync('tests/__data__/input/streams_format', 'tests/__data__/output/streams') + fs.copySync('tests/__data__/input/playlist_format', 'tests/__data__/output/streams') }) it('can format playlists', () => { @@ -13,12 +13,12 @@ it('can format playlists', () => { }) const files = glob - .sync('tests/__data__/expected/streams_format/*.m3u') - .map(f => f.replace('tests/__data__/expected/streams_format/', '')) + .sync('tests/__data__/expected/playlist_format/*.m3u') + .map(f => f.replace('tests/__data__/expected/playlist_format/', '')) files.forEach(filepath => { expect(content(`output/streams/${filepath}`), filepath).toBe( - content(`expected/streams_format/${filepath}`) + content(`expected/playlist_format/${filepath}`) ) }) }) diff --git a/tests/commands/playlist/generate.test.ts b/tests/commands/playlist/generate.test.ts index 8cdbfeee8..54c4e61e0 100644 --- a/tests/commands/playlist/generate.test.ts +++ b/tests/commands/playlist/generate.test.ts @@ -4,24 +4,26 @@ import * as glob from 'glob' beforeEach(() => { fs.emptyDirSync('tests/__data__/output') +}) +it('can generate playlists and logs', () => { execSync( - 'STREAMS_DIR=tests/__data__/input/streams_generate DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs npm run playlist:generate', + 'STREAMS_DIR=tests/__data__/input/playlist_generate DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs npm run playlist:generate', { encoding: 'utf8' } ) -}) -it('can generate playlists and logs', () => { const playlists = glob - .sync('tests/__data__/expected/.gh-pages/**/*.m3u') - .map((file: string) => file.replace('tests/__data__/expected/', '')) + .sync('tests/__data__/expected/playlist_generate/.gh-pages/**/*.m3u') + .map((file: string) => file.replace('tests/__data__/expected/playlist_generate/', '')) playlists.forEach((filepath: string) => { - expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`)) + expect(content(`output/${filepath}`), filepath).toBe( + content(`expected/playlist_generate/${filepath}`) + ) }) expect(content('output/logs/generators.log').split('\n').sort()).toStrictEqual( - content('expected/logs/generators.log').split('\n').sort() + content('expected/playlist_generate/logs/generators.log').split('\n').sort() ) }) diff --git a/tests/commands/playlist/test.test.ts b/tests/commands/playlist/test.test.ts index feb10640e..0842f0f10 100644 --- a/tests/commands/playlist/test.test.ts +++ b/tests/commands/playlist/test.test.ts @@ -7,13 +7,13 @@ type ExecError = { it('shows an error if the playlist contains a broken link', () => { try { - execSync('ROOT_DIR=tests/__data__/input npm run playlist:test streams_test/ag.m3u', { + execSync('ROOT_DIR=tests/__data__/input npm run playlist:test playlist_test/ag.m3u', { encoding: 'utf8' }) process.exit(1) } catch (error) { expect((error as ExecError).status).toBe(1) - expect((error as ExecError).stdout).toContain('streams_test/ag.m3u') + expect((error as ExecError).stdout).toContain('playlist_test/ag.m3u') expect((error as ExecError).stdout).toContain('2 problems (1 errors, 1 warnings)') } }) diff --git a/tests/commands/playlist/update.test.ts b/tests/commands/playlist/update.test.ts index 79be4f44d..cc104d8cc 100644 --- a/tests/commands/playlist/update.test.ts +++ b/tests/commands/playlist/update.test.ts @@ -4,10 +4,10 @@ import { glob } from 'glob' beforeEach(() => { fs.emptyDirSync('tests/__data__/output') - fs.copySync('tests/__data__/input/streams_update', 'tests/__data__/output/streams') + fs.copySync('tests/__data__/input/playlist_update', 'tests/__data__/output/streams') }) -it('can format playlists', () => { +it('can update playlists', () => { const stdout = execSync( 'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/output/streams npm run playlist:update --silent', { @@ -16,17 +16,17 @@ it('can format playlists', () => { ) const files = glob - .sync('tests/__data__/expected/streams_update/*.m3u') - .map(f => f.replace('tests/__data__/expected/streams_update/', '')) + .sync('tests/__data__/expected/playlist_update/*.m3u') + .map(f => f.replace('tests/__data__/expected/playlist_update/', '')) files.forEach(filepath => { expect(content(`output/streams/${filepath}`), filepath).toBe( - content(`expected/streams_update/${filepath}`) + content(`expected/playlist_update/${filepath}`) ) }) expect(stdout).toBe( - 'OUTPUT=closes #14151, closes #14140, closes #14110, closes #14120, closes #14175, closes #14105, closes #14104, closes #14057, closes #14034, closes #13964, closes #13893, closes #13881, closes #13793, closes #13751, closes #13715\n' + 'OUTPUT=closes #14151, closes #14150, closes #14110, closes #14120, closes #14175, closes #14105, closes #14104, closes #14057, closes #14034, closes #13964, closes #13893, closes #13881, closes #13793, closes #13751, closes #13715\n' ) }) diff --git a/tests/commands/playlist/validate.test.ts b/tests/commands/playlist/validate.test.ts index af1119f4d..38dd104ee 100644 --- a/tests/commands/playlist/validate.test.ts +++ b/tests/commands/playlist/validate.test.ts @@ -8,7 +8,7 @@ type ExecError = { it('show an error if channel id in the blocklist', () => { try { execSync( - 'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/streams_validate npm run playlist:validate -- us_blocked.m3u', + 'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/playlist_validate npm run playlist:validate -- us_blocked.m3u', { encoding: 'utf8' } @@ -17,7 +17,7 @@ it('show an error if channel id in the blocklist', () => { } catch (error) { expect((error as ExecError).status).toBe(1) expect((error as ExecError).stdout).toContain(`us_blocked.m3u - 2 error "FoxSports2Asia.us" is on the blocklist due to claims of copyright holders (https://github.com/iptv-org/iptv/issues/0002) + 2 error "FoxSports2.us" is on the blocklist due to claims of copyright holders (https://github.com/iptv-org/iptv/issues/0002) 4 error "TVN.pl" is on the blocklist due to NSFW content (https://github.com/iptv-org/iptv/issues/0003) 2 problems (2 errors, 0 warnings)`) @@ -26,7 +26,7 @@ it('show an error if channel id in the blocklist', () => { it('show a warning if channel has wrong id', () => { const stdout = execSync( - 'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/streams_validate npm run playlist:validate -- wrong_id.m3u', + 'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/playlist_validate npm run playlist:validate -- wrong_id.m3u', { encoding: 'utf8' } diff --git a/tests/commands/readme/update.test.ts b/tests/commands/readme/update.test.ts index 0ee6addf3..f15e71f48 100644 --- a/tests/commands/readme/update.test.ts +++ b/tests/commands/readme/update.test.ts @@ -6,23 +6,23 @@ beforeEach(() => { fs.emptyDirSync('tests/__data__/output') fs.mkdirSync('tests/__data__/output/.readme') fs.copyFileSync( - 'tests/__data__/input/.readme/config.json', + 'tests/__data__/input/readme_update/.readme/config.json', 'tests/__data__/output/.readme/config.json' ) fs.copyFileSync( - 'tests/__data__/input/.readme/template.md', + 'tests/__data__/input/readme_update/.readme/template.md', 'tests/__data__/output/.readme/template.md' ) execSync( - 'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/logs README_DIR=tests/__data__/output/.readme npm run readme:update', + 'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/readme_update README_DIR=tests/__data__/output/.readme npm run readme:update', { encoding: 'utf8' } ) }) it('can update readme.md', () => { expect(content('tests/__data__/output/readme.md')).toEqual( - content('tests/__data__/expected/_readme.md') + content('tests/__data__/expected/readme_update/_readme.md') ) }) diff --git a/tests/commands/report/create.test.ts b/tests/commands/report/create.test.ts index 219387cbb..de449347a 100644 --- a/tests/commands/report/create.test.ts +++ b/tests/commands/report/create.test.ts @@ -2,7 +2,7 @@ import { execSync } from 'child_process' it('can create report', () => { const stdout = execSync( - 'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/streams_report npm run report:create', + 'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/report_create npm run report:create', { encoding: 'utf8' } @@ -10,18 +10,15 @@ it('can create report', () => { expect( stdout.includes(` -┌─────────┬─────────────┬──────────────────┬────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────┬───────────────┐ -│ (index) │ issueNumber │ type │ channelId │ streamUrl │ status │ -├─────────┼─────────────┼──────────────────┼────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────┤ -│ 0 │ 14120 │ 'streams:edit' │ 'boo.us' │ 'https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8' │ 'invalid_id' │ -│ 1 │ 14135 │ 'streams:add' │ 'BBCWorldNewsSouthAsia.uk' │ 'http://103.199.161.254/Content/bbcworld/Live/Channel%28BBCworld%29/Stream%2801%29/index.m3u8' │ 'wrong_id' │ -│ 2 │ 14140 │ 'streams:add' │ undefined │ undefined │ 'missing_id' │ -│ 3 │ 14175 │ 'streams:add' │ 'TFX.fr' │ 'http://livetv.ktv.zone/13/play.m3u8' │ 'duplicate' │ -│ 4 │ 14177 │ 'streams:add' │ 'TUTV.us' │ 'https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8' │ 'on_playlist' │ -│ 5 │ 14178 │ 'streams:add' │ 'TV3.my' │ 'https://live-streams-ssai-01.tonton.com.my/live/2dd2b7cd-1b34-4871-b669-57b5c9beca23/live.isml/.m3u8' │ 'blocked' │ -│ 6 │ 16120 │ 'broken stream' │ undefined │ 'http://190.61.102.67:2000/play/a038/index.m3u8' │ 'wrong_link' │ -│ 7 │ 19956 │ 'channel search' │ 'CNBCe.tr' │ undefined │ 'invalid_id' │ -│ 8 │ 19957 │ 'channel search' │ '13thStreet.au' │ undefined │ 'closed' │ -└─────────┴─────────────┴──────────────────┴────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────┴───────────────┘`) +┌─────────┬─────────────┬──────────────────┬─────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────┬───────────────┐ +│ (index) │ issueNumber │ type │ streamId │ streamUrl │ status │ +├─────────┼─────────────┼──────────────────┼─────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────┤ +│ 0 │ 14120 │ 'streams:edit' │ 'boo.us' │ 'https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8' │ 'invalid_id' │ +│ 1 │ 14135 │ 'streams:add' │ 'BBCWorldNews.uk@SouthAsia' │ 'http://103.199.161.254/Content/bbcworld/Live/Channel%28BBCworld%29/Stream%2801%29/index.m3u8' │ 'wrong_id' │ +│ 2 │ 14177 │ 'streams:add' │ 'TUTV.us' │ 'https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8' │ 'on_playlist' │ +│ 3 │ 14178 │ 'streams:add' │ 'TV3.my' │ 'https://live-streams-ssai-01.tonton.com.my/live/2dd2b7cd-1b34-4871-b669-57b5c9beca23/live.isml/.m3u8...' │ 'blocked' │ +│ 4 │ 16120 │ 'broken stream' │ undefined │ 'http://190.61.102.67:2000/play/a038/index.m3u8' │ 'wrong_link' │ +│ 5 │ 19956 │ 'channel search' │ 'CNBCe.tr' │ undefined │ 'invalid_id' │ +└─────────┴─────────────┴──────────────────┴─────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────┴───────────────┘`) ).toBe(true) })