From 3aa5b392407db997dc744e3ad8478c437c408658 Mon Sep 17 00:00:00 2001 From: Martin Giger Date: Tue, 29 Aug 2017 16:54:51 +0200 Subject: [PATCH] fix tests --- _locales/de/messages.json | 4 --- _locales/en/messages.json | 4 --- _locales/es_MX/messages.json | 4 --- _locales/fr/messages.json | 4 --- _locales/hr/messages.json | 4 --- _locales/ru/messages.json | 4 --- _locales/uk_UA/messages.json | 4 --- src/background/providers/twitch.js | 2 +- src/list/components/channels.jsx | 3 ++ test/background/channel/controller.js | 49 --------------------------- test/helpers/providers/mockAPI.json | 2 +- test/list/styles.js | 2 +- 12 files changed, 6 insertions(+), 80 deletions(-) diff --git a/_locales/de/messages.json b/_locales/de/messages.json index ac4c48e6..ce632af2 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -207,10 +207,6 @@ "message": "Maximale Anfragezahl pro Aktualisierungsdurchlauf", "description": "Title of the request batch size setting in the preferences" }, - "panel_nonlive_options.Live": { - "message": "Live", - "description": "Live option of the non-live treatment setting in the preferences" - }, "errorState1": { "message": "Behebbarer Fehler in Live Stream Benachrichtigungen", "description": "Error title when a recoverable error is blocking the extension" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 7f10ffc1..20aee605 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -369,10 +369,6 @@ "message": "Non-live streams include things like hosted channels or rebroadcasts.", "description": "Description of the non-live treatment setting in the preferences" }, - "panel_nonlive_options.Live": { - "message": "Live", - "description": "Live option of the non-live treatment setting in the preferences" - }, "panel_nonlive_options.Livebottom": { "message": "Live but sort to bottom", "description": "Live sorting to bottom option of the non-live treatment setting in the preferences" diff --git a/_locales/es_MX/messages.json b/_locales/es_MX/messages.json index 6e773a6c..dd930104 100644 --- a/_locales/es_MX/messages.json +++ b/_locales/es_MX/messages.json @@ -207,10 +207,6 @@ "message": "Max Requests per Batch", "description": "Title of the request batch size setting in the preferences" }, - "panel_nonlive_options.Live": { - "message": "Live", - "description": "Live option of the non-live treatment setting in the preferences" - }, "errorState1": { "message": "Recoverable error with Live Stream Notifier", "description": "Error title when a recoverable error is blocking the extension" diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 5b8fcb93..eda662ea 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -207,10 +207,6 @@ "message": "Nombre maximal de demandes par groupe", "description": "Title of the request batch size setting in the preferences" }, - "panel_nonlive_options.Live": { - "message": "En Ligne", - "description": "Live option of the non-live treatment setting in the preferences" - }, "errorState1": { "message": "Erreur restaurable avec Live Stream Notifier", "description": "Error title when a recoverable error is blocking the extension" diff --git a/_locales/hr/messages.json b/_locales/hr/messages.json index c63d1b04..c8e1086a 100644 --- a/_locales/hr/messages.json +++ b/_locales/hr/messages.json @@ -207,10 +207,6 @@ "message": "Max Requests per Batch", "description": "Title of the request batch size setting in the preferences" }, - "panel_nonlive_options.Live": { - "message": "Live", - "description": "Live option of the non-live treatment setting in the preferences" - }, "errorState1": { "message": "Recoverable error with Live Stream Notifier", "description": "Error title when a recoverable error is blocking the extension" diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index c63d1b04..c8e1086a 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -207,10 +207,6 @@ "message": "Max Requests per Batch", "description": "Title of the request batch size setting in the preferences" }, - "panel_nonlive_options.Live": { - "message": "Live", - "description": "Live option of the non-live treatment setting in the preferences" - }, "errorState1": { "message": "Recoverable error with Live Stream Notifier", "description": "Error title when a recoverable error is blocking the extension" diff --git a/_locales/uk_UA/messages.json b/_locales/uk_UA/messages.json index c63d1b04..c8e1086a 100644 --- a/_locales/uk_UA/messages.json +++ b/_locales/uk_UA/messages.json @@ -207,10 +207,6 @@ "message": "Max Requests per Batch", "description": "Title of the request batch size setting in the preferences" }, - "panel_nonlive_options.Live": { - "message": "Live", - "description": "Live option of the non-live treatment setting in the preferences" - }, "errorState1": { "message": "Recoverable error with Live Stream Notifier", "description": "Error title when a recoverable error is blocking the extension" diff --git a/src/background/providers/twitch.js b/src/background/providers/twitch.js index 269b9399..49ac9e2d 100644 --- a/src/background/providers/twitch.js +++ b/src/background/providers/twitch.js @@ -302,7 +302,7 @@ class Twitch extends GenericProvider { return ret; } async getFeaturedChannels() { - const data = await this._qs.queueRequest(`${baseURL}/streams/featured?boradcaster_language=${browser.i18n.getUILanguage().substr(0, 2)}`, headers); + const data = await this._qs.queueRequest(`${baseURL}/streams/featured?broadcaster_language=${browser.i18n.getUILanguage().substr(0, 2)}`, headers); if(data.parsedJSON && "featured" in data.parsedJSON && data.parsedJSON.featured.length) { let chans = data.parsedJSON.featured; if(await not(this._mature())) { diff --git a/src/list/components/channels.jsx b/src/list/components/channels.jsx index 86168227..800b3f9d 100644 --- a/src/list/components/channels.jsx +++ b/src/list/components/channels.jsx @@ -293,6 +293,9 @@ const getChannelList = (channels, type, nonLiveDisplay) => { shownChannels.push(channel); } else if(channel.live.state === LiveState.REDIRECT) { + if(!channel.live.alternateChannel) { + console.warn("this shouldn't be here", channel); + } if("id" in channel.live.alternateChannel) { internalRedirects.push(channel); } diff --git a/test/background/channel/controller.js b/test/background/channel/controller.js index 1e473d2a..138748c4 100644 --- a/test/background/channel/controller.js +++ b/test/background/channel/controller.js @@ -10,8 +10,6 @@ import test from 'ava'; import ChannelController from "../../../src/background/channel/controller"; import providers from "../../../src/background/providers"; import { getMockAPIQS, IGNORE_QSUPDATE_PROVIDERS } from "../../helpers/providers/mock-qs"; -import prefs from '../../../src/prefs.json'; -import { getChannel } from '../../helpers/channel-user'; const TESTUSER = { name: "freaktechnik", @@ -294,53 +292,6 @@ test('getExternalChannel', async (t) => { t.false('id' in channel); }); -test('copyableChannelURL throws with unknown type for external channel', async (t) => { - const cc = new ChannelController(); - await cc._ensureQueueReady(); - - return t.throws(cc.copyableChannelURL('foo', 'bar')); -}); - -test('copyableChannelURL for external channel', async (t) => { - const cc = new ChannelController(); - await cc._ensureQueueReady(); - - const string = await cc.copyableChannelURL(TESTUSER.name, TESTUSER.type); - - t.false(string.includes('{URL}')); - t.is(string, prefs.copy_pattern.value.replace('{URL}', `http://www.twitch.tv/${TESTUSER.name}`)); -}); - -test.serial('copyableChannelURL for channel from list', async (t) => { - const cc = new ChannelController(); - await cc._ensureQueueReady(); - - const channel = await cc.addChannel(TESTUSER.name, TESTUSER.type); - - const string = await cc.copyableChannelURL(channel.id); - - t.false(string.includes('{URL}')); - t.is(string, prefs.copy_pattern.value.replace('{URL}', channel.url[0])); - - await cc.removeChannel(channel.id); -}); - -test.serial('copyableChannelURL for redirecting channel from list', async (t) => { - const cc = new ChannelController(); - await cc._ensureQueueReady(); - - const channel = await cc.addChannel(TESTUSER.name, TESTUSER.type); - channel.live.redirectTo(getChannel()); - await cc._list.setChannel(channel); - - const string = await cc.copyableChannelURL(channel.id); - - t.false(string.includes('{URL}')); - t.is(string, prefs.copy_pattern.value.replace('{URL}', channel.live.alternateURL)); - - await cc.removeChannel(channel.id); -}); - let oldQS; test.before(() => { const provider = providers[TESTUSER.type]; diff --git a/test/helpers/providers/mockAPI.json b/test/helpers/providers/mockAPI.json index d31fc3a5..85c43cb0 100644 --- a/test/helpers/providers/mockAPI.json +++ b/test/helpers/providers/mockAPI.json @@ -768,7 +768,7 @@ "https://tmi.twitch.tv/hosts?include_logins=1&host=0": { "hosts": [] }, - "https://api.twitch.tv/kraken/streams/featured": { + "https://api.twitch.tv/kraken/streams/featured?broadcaster_language=en": { "featured": [ { "stream": { diff --git a/test/list/styles.js b/test/list/styles.js index 5b7696fa..c1ebe693 100644 --- a/test/list/styles.js +++ b/test/list/styles.js @@ -11,6 +11,6 @@ test("Provider Styles", async (t) => { const styles = await fs.readFile(path.join(__dirname, '../../src/list/list.css')); for(const provider in providers) { - t.true(styles.includes("." + provider + " a"), "Color definitions for " + provider + " exist"); + t.true(styles.includes(`.tabcontent > ul > .${provider}`), "Color definitions for " + provider + " exist"); } });