From 56ccf2ac1b53d88b110d153ac3aed5dd746c2231 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sun, 3 May 2026 21:37:06 +0300 Subject: [PATCH] Update grab.test.ts --- tests/commands/epg/grab.test.ts | 77 +++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/tests/commands/epg/grab.test.ts b/tests/commands/epg/grab.test.ts index b2a965c3b..743cb0fb7 100644 --- a/tests/commands/epg/grab.test.ts +++ b/tests/commands/epg/grab.test.ts @@ -90,21 +90,20 @@ describe('epg:grab', () => { it('can grab epg with gzip option enabled', () => { const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/sites/example2.com/example2.com.channels.xml --output="${path.resolve( - 'tests/__data__/output/guides/gzip.guide.xml' - )}" --gzip ` + 'tests/__data__/output/guides/guide.xml' + )}" --gzip` const stdout = execSync(cmd, { encoding: 'utf8' }) if (process.env.DEBUG === 'true') console.log(cmd, stdout) - expect(content('tests/__data__/output/guides/gzip.guide.xml')).toEqual( - content('tests/__data__/expected/epg_grab/gzip.guide.xml') + expect(content('tests/__data__/output/guides/guide.xml')).toEqual( + content('tests/__data__/expected/epg_grab/gzip/guide.xml') ) - const outputString = pako.ungzip( - fs.readFileSync('tests/__data__/output/guides/gzip.guide.xml.gz'), - { to: 'string' } - ) + const outputString = pako.ungzip(fs.readFileSync('tests/__data__/output/guides/guide.xml.gz'), { + to: 'string' + }) const expectedString = pako.ungzip( - fs.readFileSync('tests/__data__/expected/epg_grab/gzip.guide.xml.gz'), + fs.readFileSync('tests/__data__/expected/epg_grab/gzip/guide.xml.gz'), { to: 'string' } ) @@ -113,6 +112,66 @@ describe('epg:grab', () => { expect(output).toEqual(expected) }) + + it('can grab epg with gzip option enabled', () => { + const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/sites/example2.com/example2.com.channels.xml --output="${path.resolve( + 'tests/__data__/output/guides/guide.xml' + )}" --gzip="${path.resolve('tests/__data__/output/guides/custom.xml.gz')}"` + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + + expect(content('tests/__data__/output/guides/guide.xml')).toEqual( + content('tests/__data__/expected/epg_grab/gzip/guide.xml') + ) + + const outputString = pako.ungzip( + fs.readFileSync('tests/__data__/output/guides/custom.xml.gz'), + { + to: 'string' + } + ) + const expectedString = pako.ungzip( + fs.readFileSync('tests/__data__/expected/epg_grab/gzip/guide.xml.gz'), + { to: 'string' } + ) + + const output = new Set(outputString.split('\r\n')) + const expected = new Set(expectedString.split('\r\n')) + + expect(output).toEqual(expected) + }) + + it('can grab epg with json option enabled', () => { + const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/sites/example2.com/example2.com.channels.xml --output="${path.resolve( + 'tests/__data__/output/guides/guide.xml' + )}" --json` + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + + expect(content('tests/__data__/output/guides/guide.xml')).toEqual( + content('tests/__data__/expected/epg_grab/json/guide.xml') + ) + + expect(content('tests/__data__/output/guides/guide.json')).toEqual( + content('tests/__data__/expected/epg_grab/json/guide.json') + ) + }) + + it('can grab epg with json option enabled', () => { + const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/sites/example2.com/example2.com.channels.xml --output="${path.resolve( + 'tests/__data__/output/guides/guide.xml' + )}" --json="${path.resolve('tests/__data__/output/guides/custom.json')}"` + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + + expect(content('tests/__data__/output/guides/guide.xml')).toEqual( + content('tests/__data__/expected/epg_grab/json/guide.xml') + ) + + expect(content('tests/__data__/output/guides/custom.json')).toEqual( + content('tests/__data__/expected/epg_grab/json/guide.json') + ) + }) }) function content(filepath: string) {