mirror of
https://github.com/iptv-org/iptv-org.github.io.git
synced 2025-05-10 17:10:06 -04:00
Create tests
This commit is contained in:
parent
0a172ae9c9
commit
e3bc9558d0
14 changed files with 9076 additions and 91 deletions
6659
package-lock.json
generated
6659
package-lock.json
generated
File diff suppressed because it is too large
Load diff
10
package.json
10
package.json
|
@ -8,7 +8,14 @@
|
|||
"build": "NODE_OPTIONS=--max_old_space_size=4096 vite build",
|
||||
"preview": "vite preview",
|
||||
"postbuild": "npx svelte-sitemap -d https://iptv-org.github.io -o docs",
|
||||
"postinstall": "node ./src/load.js"
|
||||
"postinstall": "node ./src/load.js",
|
||||
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {},
|
||||
"moduleNameMapper": {
|
||||
"^\\$app/environment$": "<rootDir>/tests/__mocks__/$app/environment.js"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@freearhey/core": "^0.5.1",
|
||||
|
@ -22,6 +29,7 @@
|
|||
"cli-progress": "^3.12.0",
|
||||
"dayjs": "^1.11.1",
|
||||
"iptv-playlist-generator": "^0.1.5",
|
||||
"jest": "^29.7.0",
|
||||
"lodash": "^4.17.21",
|
||||
"numeral": "^2.0.6",
|
||||
"postcss": "^8.5.1",
|
||||
|
|
7
tests/__data__/input/blocklist.json
Normal file
7
tests/__data__/input/blocklist.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
{
|
||||
"channel": "Bizarre.al",
|
||||
"reason": "nsfw",
|
||||
"ref": "https://github.com/iptv-org/iptv/issues/15723"
|
||||
}
|
||||
]
|
1
tests/__data__/input/categories.json
Normal file
1
tests/__data__/input/categories.json
Normal file
|
@ -0,0 +1 @@
|
|||
[]
|
379
tests/__data__/input/channels.json
Normal file
379
tests/__data__/input/channels.json
Normal file
|
@ -0,0 +1,379 @@
|
|||
[
|
||||
{
|
||||
"id": "002RadioTV.do",
|
||||
"name": "002 Radio TV",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [],
|
||||
"country": "DO",
|
||||
"subdivision": null,
|
||||
"city": "Santo Domingo",
|
||||
"broadcast_area": [
|
||||
"c/DO"
|
||||
],
|
||||
"languages": [
|
||||
"spa"
|
||||
],
|
||||
"categories": [
|
||||
"general"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://www.002radio.com/",
|
||||
"logo": "https://i.imgur.com/7oNe8xj.png"
|
||||
},
|
||||
{
|
||||
"id": "01TV.fr",
|
||||
"name": "01 TV",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [],
|
||||
"country": "FR",
|
||||
"subdivision": null,
|
||||
"city": "Boulogne",
|
||||
"broadcast_area": [
|
||||
"c/FR"
|
||||
],
|
||||
"languages": [
|
||||
"fra"
|
||||
],
|
||||
"categories": [
|
||||
"education",
|
||||
"news"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://www.01net.com/tag/01nettv/",
|
||||
"logo": "https://i.imgur.com/RMucFq8.png"
|
||||
},
|
||||
{
|
||||
"id": "FashionTVJohannesburg.fr",
|
||||
"name": "FashionTV Johannesburg",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [
|
||||
"Michel Adam Lisowski"
|
||||
],
|
||||
"country": "FR",
|
||||
"subdivision": null,
|
||||
"city": "Paris",
|
||||
"broadcast_area": [
|
||||
"c/FR"
|
||||
],
|
||||
"languages": [
|
||||
"eng"
|
||||
],
|
||||
"categories": [
|
||||
"lifestyle"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": "2000-10-01",
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://www.fashiontv.com/",
|
||||
"logo": "https://i.imgur.com/6u4tZn6.png"
|
||||
},
|
||||
{
|
||||
"id": "XtremaCartoons.ar",
|
||||
"name": "Xtrema Cartoons",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [],
|
||||
"country": "AR",
|
||||
"subdivision": null,
|
||||
"city": null,
|
||||
"broadcast_area": [
|
||||
"c/AR"
|
||||
],
|
||||
"languages": [
|
||||
"spa"
|
||||
],
|
||||
"categories": [
|
||||
"animation",
|
||||
"kids"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://xtrematv.com/",
|
||||
"logo": "https://i.imgur.com/X2d8y4e.png"
|
||||
},
|
||||
{
|
||||
"id": "XtremaRetroCartoons.ar",
|
||||
"name": "Xtrema Retro Cartoons",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [],
|
||||
"country": "AR",
|
||||
"subdivision": null,
|
||||
"city": null,
|
||||
"broadcast_area": [
|
||||
"c/AR"
|
||||
],
|
||||
"languages": [
|
||||
"spa"
|
||||
],
|
||||
"categories": [
|
||||
"animation"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": null,
|
||||
"logo": "https://i.imgur.com/60ylWbQ.png"
|
||||
},
|
||||
{
|
||||
"id": "TV1.dz",
|
||||
"name": "TV1",
|
||||
"alt_names": [
|
||||
"الجزائرية الأولى",
|
||||
"Algerian Television",
|
||||
"التلفزيون الجزائري",
|
||||
"The Terrestrial Channel",
|
||||
"القناة الأرضية"
|
||||
],
|
||||
"network": null,
|
||||
"owners": [
|
||||
"EPTV"
|
||||
],
|
||||
"country": "DZ",
|
||||
"subdivision": null,
|
||||
"city": "Algiers",
|
||||
"broadcast_area": [
|
||||
"c/DZ"
|
||||
],
|
||||
"languages": [
|
||||
"ara",
|
||||
"fra"
|
||||
],
|
||||
"categories": [
|
||||
"general"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": "1956-12-24",
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://www.entv.dz/",
|
||||
"logo": "https://i.imgur.com/F0DOrxX.png"
|
||||
},
|
||||
{
|
||||
"id": "K11UUD1.as",
|
||||
"name": "K11UU-D1",
|
||||
"alt_names": [],
|
||||
"network": "Hope Channel",
|
||||
"owners": [
|
||||
"American Samoa Adventist Media Ministry Inc"
|
||||
],
|
||||
"country": "AS",
|
||||
"subdivision": null,
|
||||
"city": "Pago Pago",
|
||||
"broadcast_area": [
|
||||
"c/AS"
|
||||
],
|
||||
"languages": [
|
||||
"eng"
|
||||
],
|
||||
"categories": [
|
||||
"religious"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": "2003-10-14",
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://asamtv.org/",
|
||||
"logo": "https://i.imgur.com/NQD8Zer.png"
|
||||
},
|
||||
{
|
||||
"id": "13MaxTelevision.ar",
|
||||
"name": "13Max Television",
|
||||
"alt_names": [
|
||||
"13Max Televisión"
|
||||
],
|
||||
"network": null,
|
||||
"owners": [
|
||||
"Río Paraná TV SRL"
|
||||
],
|
||||
"country": "AR",
|
||||
"subdivision": "AR-W",
|
||||
"city": "Corrientes",
|
||||
"broadcast_area": [
|
||||
"s/AR-W"
|
||||
],
|
||||
"languages": [
|
||||
"spa"
|
||||
],
|
||||
"categories": [
|
||||
"general"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": "1965-01-01",
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://live-tv-channels.org/livetv/ar-13-max-tv.html",
|
||||
"logo": "https://i.imgur.com/QvF4l2t.png"
|
||||
},
|
||||
{
|
||||
"id": "Bizarre.al",
|
||||
"name": "Bizarre",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [],
|
||||
"country": "AL",
|
||||
"subdivision": null,
|
||||
"city": null,
|
||||
"broadcast_area": [
|
||||
"c/AL"
|
||||
],
|
||||
"languages": [
|
||||
"sqi"
|
||||
],
|
||||
"categories": [
|
||||
"xxx"
|
||||
],
|
||||
"is_nsfw": true,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "http://www.tring.al/",
|
||||
"logo": "https://i.imgur.com/vpS477d.png"
|
||||
},
|
||||
{
|
||||
"id": "AynaTV.af",
|
||||
"name": "Ayna TV",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [
|
||||
"Abdul Rashid Dostum"
|
||||
],
|
||||
"country": "AF",
|
||||
"subdivision": null,
|
||||
"city": "Kabul",
|
||||
"broadcast_area": [
|
||||
"c/AF"
|
||||
],
|
||||
"languages": [
|
||||
"pus"
|
||||
],
|
||||
"categories": [
|
||||
"general"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": "2004-01-01",
|
||||
"closed": "2022-02-16",
|
||||
"replaced_by": null,
|
||||
"website": "http://www.ayna.af/",
|
||||
"logo": "https://i.imgur.com/2tHlT5Q.png"
|
||||
},
|
||||
{
|
||||
"id": "LaLiganaZap.ao",
|
||||
"name": "LaLiga na Zap",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [
|
||||
"ZAP Angola"
|
||||
],
|
||||
"country": "AO",
|
||||
"subdivision": null,
|
||||
"city": null,
|
||||
"broadcast_area": [
|
||||
"c/AO"
|
||||
],
|
||||
"languages": [
|
||||
"por"
|
||||
],
|
||||
"categories": [
|
||||
"sports"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://www.zap.co.ao/",
|
||||
"logo": "https://i.imgur.com/NWFShcJ.png"
|
||||
},
|
||||
{
|
||||
"id": "SEN502.us",
|
||||
"name": "SEN 502",
|
||||
"alt_names": [
|
||||
"TV2 Sports"
|
||||
],
|
||||
"network": null,
|
||||
"owners": [],
|
||||
"country": "US",
|
||||
"subdivision": null,
|
||||
"city": null,
|
||||
"broadcast_area": [
|
||||
"c/US"
|
||||
],
|
||||
"languages": [
|
||||
"eng"
|
||||
],
|
||||
"categories": [
|
||||
"sports"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://www.senetwork.tv/",
|
||||
"logo": "https://i.imgur.com/cEGW3pw.png"
|
||||
},
|
||||
{
|
||||
"id": "SEN550.us",
|
||||
"name": "SEN 550",
|
||||
"alt_names": [],
|
||||
"network": null,
|
||||
"owners": [],
|
||||
"country": "US",
|
||||
"subdivision": null,
|
||||
"city": null,
|
||||
"broadcast_area": [
|
||||
"c/US"
|
||||
],
|
||||
"languages": [
|
||||
"eng"
|
||||
],
|
||||
"categories": [
|
||||
"sports"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://www.senetwork.tv/",
|
||||
"logo": "https://i.imgur.com/T4vLkeH.png"
|
||||
},
|
||||
{
|
||||
"id": "CFCNTV2.ca",
|
||||
"name": "CFCN-TV-2",
|
||||
"alt_names": [],
|
||||
"network": "CTV",
|
||||
"owners": [
|
||||
"Bell Media"
|
||||
],
|
||||
"country": "CA",
|
||||
"subdivision": "CA-AB",
|
||||
"city": "Banff",
|
||||
"broadcast_area": [
|
||||
"s/CA-AB"
|
||||
],
|
||||
"languages": [
|
||||
"eng"
|
||||
],
|
||||
"categories": [
|
||||
"general"
|
||||
],
|
||||
"is_nsfw": false,
|
||||
"launched": null,
|
||||
"closed": null,
|
||||
"replaced_by": null,
|
||||
"website": "https://calgary.ctvnews.ca/",
|
||||
"logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/CTV_logo_2018.svg/512px-CTV_logo_2018.svg.png"
|
||||
}
|
||||
]
|
1
tests/__data__/input/countries.json
Normal file
1
tests/__data__/input/countries.json
Normal file
|
@ -0,0 +1 @@
|
|||
[{"name":"Dominican Republic","code":"DO","languages":["spa"],"flag":"🇩🇴"}]
|
9
tests/__data__/input/guides.json
Normal file
9
tests/__data__/input/guides.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
{
|
||||
"channel": "LaLiganaZap.ao",
|
||||
"site": "zap.co.ao",
|
||||
"site_id": "2386",
|
||||
"site_name": "La Liga HD",
|
||||
"lang": "pt"
|
||||
}
|
||||
]
|
1
tests/__data__/input/languages.json
Normal file
1
tests/__data__/input/languages.json
Normal file
|
@ -0,0 +1 @@
|
|||
[]
|
1
tests/__data__/input/regions.json
Normal file
1
tests/__data__/input/regions.json
Normal file
|
@ -0,0 +1 @@
|
|||
[]
|
9
tests/__data__/input/streams.json
Normal file
9
tests/__data__/input/streams.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
{
|
||||
"channel": "XtremaCartoons.ar",
|
||||
"url": "https://stmv6.voxtvhd.com.br/xtremacartoons/xtremacartoons/playlist.m3u8",
|
||||
"timeshift": null,
|
||||
"http_referrer": "https://xtrematv.com/?p=1390",
|
||||
"user_agent": null
|
||||
}
|
||||
]
|
1
tests/__data__/input/subdivisions.json
Normal file
1
tests/__data__/input/subdivisions.json
Normal file
|
@ -0,0 +1 @@
|
|||
[]
|
1
tests/__mocks__/$app/environment.js
Normal file
1
tests/__mocks__/$app/environment.js
Normal file
|
@ -0,0 +1 @@
|
|||
export const browser = true
|
289
tests/store.test.js
Normal file
289
tests/store.test.js
Normal file
|
@ -0,0 +1,289 @@
|
|||
import { search, fetchChannels, filteredChannels } from '../src/store'
|
||||
import { get } from 'svelte/store'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { jest } from '@jest/globals'
|
||||
|
||||
const API_ENDPOINT = 'https://iptv-org.github.io/api'
|
||||
|
||||
beforeEach(async () => {
|
||||
global.fetch = mockFetch()
|
||||
await fetchChannels()
|
||||
})
|
||||
|
||||
describe('search', () => {
|
||||
it('return all channels by default', () => {
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(14)
|
||||
})
|
||||
|
||||
it('returns empty list if there is no such channel', () => {
|
||||
search('lorem')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(0)
|
||||
})
|
||||
|
||||
it('can find channel by name', () => {
|
||||
search('name:002')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '002RadioTV.do'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find channels by multiple words', () => {
|
||||
search('Xtrema Cartoons')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(2)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'XtremaCartoons.ar'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
id: 'XtremaRetroCartoons.ar'
|
||||
})
|
||||
})
|
||||
|
||||
it('can search for one of two words', () => {
|
||||
search('Johannesburg,002')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(2)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '002RadioTV.do'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
id: 'FashionTVJohannesburg.fr'
|
||||
})
|
||||
})
|
||||
|
||||
it('can search for exact word matches', () => {
|
||||
search('"Xtrema Cartoons"')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'XtremaCartoons.ar'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find channels by id', () => {
|
||||
search('id:002RadioTV.do')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '002RadioTV.do'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find channels by alternative names', () => {
|
||||
search('alt_names:التلفزيون')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'TV1.dz'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find channels by network', () => {
|
||||
search('network:Hope')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'K11UUD1.as'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find channels without the owner', () => {
|
||||
search('owners:^$')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(7)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '002RadioTV.do'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find channels by country', () => {
|
||||
search('country:DO')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '002RadioTV.do'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all channels that are broadcast from the same region', () => {
|
||||
search('subdivision:AR-W')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '13MaxTelevision.ar'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all channels that are broadcast from the same city', () => {
|
||||
search('city:Corrientes')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '13MaxTelevision.ar'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all channels that are broadcast in the same region', () => {
|
||||
search('broadcast_area:s/AR-W')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '13MaxTelevision.ar'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all channels that are broadcast in the same language', () => {
|
||||
search('languages:spa')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(4)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '002RadioTV.do'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all channels that have the same category', () => {
|
||||
search('categories:lifestyle')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'FashionTVJohannesburg.fr'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all channels with website', () => {
|
||||
search('website:.')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(13)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: '002RadioTV.do'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all channels marked as NSFW', () => {
|
||||
search('is_nsfw:true')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'Bizarre.al'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all closed channels', () => {
|
||||
search('is_closed:true')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'AynaTV.af'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all blocked channels', () => {
|
||||
search('is_blocked:true')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'Bizarre.al'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all the channels that have streams', () => {
|
||||
search('streams:>0')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'XtremaCartoons.ar'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find all the channels that have guides', () => {
|
||||
search('guides:>0')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'LaLiganaZap.ao'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find channels by query in lower case', () => {
|
||||
search('tv2')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(2)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'SEN502.us'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
id: 'CFCNTV2.ca'
|
||||
})
|
||||
})
|
||||
|
||||
it('can find channel by alternative name after another query', () => {
|
||||
search('tv2')
|
||||
search('alt_names:tv2')
|
||||
|
||||
const results = get(filteredChannels)
|
||||
expect(results.length).toBe(1)
|
||||
expect(results[0]).toMatchObject({
|
||||
id: 'SEN502.us'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function mockFetch() {
|
||||
return jest.fn().mockImplementation(url =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () => {
|
||||
if (url === `${API_ENDPOINT}/channels.json`)
|
||||
return loadJson('tests/__data__/input/channels.json')
|
||||
if (url === `${API_ENDPOINT}/countries.json`)
|
||||
return loadJson('tests/__data__/input/countries.json')
|
||||
if (url === `${API_ENDPOINT}/languages.json`)
|
||||
return loadJson('tests/__data__/input/languages.json')
|
||||
if (url === `${API_ENDPOINT}/guides.json`)
|
||||
return loadJson('tests/__data__/input/guides.json')
|
||||
if (url === `${API_ENDPOINT}/regions.json`)
|
||||
return loadJson('tests/__data__/input/regions.json')
|
||||
if (url === `${API_ENDPOINT}/blocklist.json`)
|
||||
return loadJson('tests/__data__/input/blocklist.json')
|
||||
if (url === `${API_ENDPOINT}/subdivisions.json`)
|
||||
return loadJson('tests/__data__/input/subdivisions.json')
|
||||
if (url === `${API_ENDPOINT}/categories.json`)
|
||||
return loadJson('tests/__data__/input/categories.json')
|
||||
if (url === `${API_ENDPOINT}/streams.json`)
|
||||
return loadJson('tests/__data__/input/streams.json')
|
||||
return []
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
function loadJson(filepath) {
|
||||
return JSON.parse(fs.readFileSync(path.resolve(filepath), 'utf8'))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue