mirror of
https://github.com/iptv-org/epg
synced 2026-05-09 10:57:03 -04:00
Update grab.test.ts
This commit is contained in:
@@ -90,21 +90,20 @@ describe('epg:grab', () => {
|
|||||||
|
|
||||||
it('can grab epg with gzip option enabled', () => {
|
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(
|
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'
|
'tests/__data__/output/guides/guide.xml'
|
||||||
)}" --gzip `
|
)}" --gzip`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guides/gzip.guide.xml')).toEqual(
|
expect(content('tests/__data__/output/guides/guide.xml')).toEqual(
|
||||||
content('tests/__data__/expected/epg_grab/gzip.guide.xml')
|
content('tests/__data__/expected/epg_grab/gzip/guide.xml')
|
||||||
)
|
)
|
||||||
|
|
||||||
const outputString = pako.ungzip(
|
const outputString = pako.ungzip(fs.readFileSync('tests/__data__/output/guides/guide.xml.gz'), {
|
||||||
fs.readFileSync('tests/__data__/output/guides/gzip.guide.xml.gz'),
|
to: 'string'
|
||||||
{ to: 'string' }
|
})
|
||||||
)
|
|
||||||
const expectedString = pako.ungzip(
|
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' }
|
{ to: 'string' }
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -113,6 +112,66 @@ describe('epg:grab', () => {
|
|||||||
|
|
||||||
expect(output).toEqual(expected)
|
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) {
|
function content(filepath: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user