From 9ee883a1500cb795498db3bdd405519a37c85485 Mon Sep 17 00:00:00 2001 From: Marco Kreeft Date: Sun, 25 Dec 2022 17:48:41 +0100 Subject: [PATCH] Fix tests --- tests/cards/driver-standings.test.ts | 2 +- tests/cards/last-result.test.ts | 6 +++--- tests/cards/next-race.test.ts | 10 +++++----- tests/utils/getCountryFlagUrl.test.ts | 11 +++++------ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/cards/driver-standings.test.ts b/tests/cards/driver-standings.test.ts index 236890b..946cd5e 100644 --- a/tests/cards/driver-standings.test.ts +++ b/tests/cards/driver-standings.test.ts @@ -56,7 +56,7 @@ describe('Testing driver-standings file', () => { const result = card.render(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('
  Driver Team Pts Wins
1  VER Max Verstappen Red Bull 341 11
2  LEC Charles Leclerc Ferrari 237 3
3  PER Sergio Pérez Red Bull 235 2
4  RUS George Russell Mercedes 203 0
5  SAI Carlos Sainz Ferrari 202 1
6  HAM Lewis Hamilton Mercedes 170 0
7  NOR Lando Norris McLaren 100 0
8  OCO Esteban Ocon Alpine F1 Team 66 0
9  ALO Fernando Alonso Alpine F1 Team 59 0
10  BOT Valtteri Bottas Alfa Romeo 46 0
11  RIC Daniel Ricciardo McLaren 29 0
12  VET Sebastian Vettel Aston Martin 24 0
13  GAS Pierre Gasly AlphaTauri 23 0
14  MAG Kevin Magnussen Haas F1 Team 22 0
15  STR Lance Stroll Aston Martin 13 0
16  MSC Mick Schumacher Haas F1 Team 12 0
17  TSU Yuki Tsunoda AlphaTauri 11 0
18  ZHO Guanyu Zhou Alfa Romeo 6 0
19  ALB Alexander Albon Williams 4 0
20  DEV Nyck de Vries Williams 2 0
21  LAT Nicholas Latifi Williams 0 0
22  HUL Nico Hülkenberg Aston Martin 0 0
'); + expect(htmlResult).toMatch('
  Driver Team Pts Wins
1  VER Max Verstappen Red Bull 341 11
2  LEC Charles Leclerc Ferrari 237 3
3  PER Sergio Pérez Red Bull 235 2
4  RUS George Russell Mercedes 203 0
5  SAI Carlos Sainz Ferrari 202 1
6  HAM Lewis Hamilton Mercedes 170 0
7  NOR Lando Norris McLaren 100 0
8  OCO Esteban Ocon Alpine F1 Team 66 0
9  ALO Fernando Alonso Alpine F1 Team 59 0
10  BOT Valtteri Bottas Alfa Romeo 46 0
11  RIC Daniel Ricciardo McLaren 29 0
12  VET Sebastian Vettel Aston Martin 24 0
13  GAS Pierre Gasly AlphaTauri 23 0
14  MAG Kevin Magnussen Haas F1 Team 22 0
15  STR Lance Stroll Aston Martin 13 0
16  MSC Mick Schumacher Haas F1 Team 12 0
17  TSU Yuki Tsunoda AlphaTauri 11 0
18  ZHO Guanyu Zhou Alfa Romeo 6 0
19  ALB Alexander Albon Williams 4 0
20  DEV Nyck de Vries Williams 2 0
21  LAT Nicholas Latifi Williams 0 0
22  HUL Nico Hülkenberg Aston Martin 0 0
'); }), test('Calling cardSize with hass and sensor', () => { diff --git a/tests/cards/last-result.test.ts b/tests/cards/last-result.test.ts index 67cee4c..a86b937 100644 --- a/tests/cards/last-result.test.ts +++ b/tests/cards/last-result.test.ts @@ -40,7 +40,7 @@ describe('Testing last-result file', () => { const result = card.render(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('

  17 : Singapore Grand Prix


  Driver Grid Points Status
1 Sergio Pérez 2 25 Finished
2 Charles Leclerc 1 18 Finished
3 Carlos Sainz 4 15 Finished
4 Lando Norris 6 12 Finished
5 Daniel Ricciardo 16 10 Finished
6 Lance Stroll 11 8 Finished
7 Max Verstappen 8 6 Finished
8 Sebastian Vettel 13 4 Finished
9 Lewis Hamilton 3 2 Finished
10 Pierre Gasly 7 1 Finished
11 Valtteri Bottas 15 0 Finished
12 Kevin Magnussen 9 0 Finished
13 Mick Schumacher 12 0 +1 Lap
14 George Russell 0 0 +2 Laps
15 Yuki Tsunoda 10 0 Accident
16 Esteban Ocon 17 0 Engine
17 Alexander Albon 18 0 Collision damage
18 Fernando Alonso 5 0 Engine
19 Nicholas Latifi 19 0 Collision damage
20 Guanyu Zhou 14 0 Collision
'); + expect(htmlResult).toMatch('

  17 : Singapore Grand Prix


  Driver Grid Points Status
1 Sergio Pérez 2 25 Finished
2 Charles Leclerc 1 18 Finished
3 Carlos Sainz 4 15 Finished
4 Lando Norris 6 12 Finished
5 Daniel Ricciardo 16 10 Finished
6 Lance Stroll 11 8 Finished
7 Max Verstappen 8 6 Finished
8 Sebastian Vettel 13 4 Finished
9 Lewis Hamilton 3 2 Finished
10 Pierre Gasly 7 1 Finished
11 Valtteri Bottas 15 0 Finished
12 Kevin Magnussen 9 0 Finished
13 Mick Schumacher 12 0 +1 Lap
14 George Russell 0 0 +2 Laps
15 Yuki Tsunoda 10 0 Accident
16 Esteban Ocon 17 0 Engine
17 Alexander Albon 18 0 Collision damage
18 Fernando Alonso 5 0 Engine
19 Nicholas Latifi 19 0 Collision damage
20 Guanyu Zhou 14 0 Collision
'); }), test('Calling renderHeader with hass and wrong sensor', () => { hass.states = { @@ -53,7 +53,7 @@ describe('Testing last-result file', () => { const result = card.renderHeader(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('

  17 : Singapore Grand Prix


'); + expect(htmlResult).toMatch('

  17 : Singapore Grand Prix


'); }), test('Calling renderHeader clickable image with hass and wrong sensor', () => { hass.states = { @@ -66,7 +66,7 @@ describe('Testing last-result file', () => { const result = card.renderHeader(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('

  17 : Singapore Grand Prix


'); + expect(htmlResult).toMatch('

  17 : Singapore Grand Prix


'); }), test('Calling cardSize with hass and sensor', () => { diff --git a/tests/cards/next-race.test.ts b/tests/cards/next-race.test.ts index 4d10b14..0c4e9c3 100644 --- a/tests/cards/next-race.test.ts +++ b/tests/cards/next-race.test.ts @@ -46,7 +46,7 @@ describe('Testing next-race file', () => { const result = card.render(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


Date20-03-22 Practice 1vr 13:00
Race1 Practice 2vr 16:00
Race nameBahrain Grand Prix Practice 3za 13:00
Circuit nameBahrain International Circuit Qualifyingza 16:00
LocationBahrain Sprint-
CitySakhir Racezo 16:00
'); + expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


Date20-03-22 Practice 1vr 13:00
Race1 Practice 2vr 16:00
Race nameBahrain Grand Prix Practice 3za 13:00
Circuit nameBahrain International Circuit Qualifyingza 16:00
LocationBahrain Sprint-
CitySakhir Racezo 16:00
'); }), test('Calling renderHeader with hass and wrong sensor', () => { hass.states = { @@ -59,7 +59,7 @@ describe('Testing next-race file', () => { const result = card.renderHeader(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


'); + expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


'); }), test('Calling renderHeader clickable image with hass and wrong sensor', () => { hass.states = { @@ -72,7 +72,7 @@ describe('Testing next-race file', () => { const result = card.renderHeader(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


'); + expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


'); }), test('Calling render without Qualifying with hass and sensor', () => { const raceData = data as Race; @@ -86,7 +86,7 @@ describe('Testing next-race file', () => { const result = card.render(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


Date20-03-22 Practice 1vr 13:00
Race1 Practice 2vr 16:00
Race nameBahrain Grand Prix Practice 3za 13:00
Circuit nameBahrain International Circuit Qualifying-
LocationBahrain Sprint-
CitySakhir Racezo 16:00
'); + expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


Date20-03-22 Practice 1vr 13:00
Race1 Practice 2vr 16:00
Race nameBahrain Grand Prix Practice 3za 13:00
Circuit nameBahrain International Circuit Qualifying-
LocationBahrain Sprint-
CitySakhir Racezo 16:00
'); }), test('Calling render with Sprint with hass and sensor', () => { const raceData = data as Race; @@ -104,7 +104,7 @@ describe('Testing next-race file', () => { const result = card.render(); const htmlResult = getRenderString(result); - expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


Date20-03-22 Practice 1vr 13:00
Race1 Practice 2vr 16:00
Race nameBahrain Grand Prix Practice 3-
Circuit nameBahrain International Circuit Qualifying-
LocationBahrain Sprintzo 10:00
CitySakhir Racezo 16:00
'); + expect(htmlResult).toMatch('

  1 : Bahrain Grand Prix


Date20-03-22 Practice 1vr 13:00
Race1 Practice 2vr 16:00
Race nameBahrain Grand Prix Practice 3-
Circuit nameBahrain International Circuit Qualifying-
LocationBahrain Sprintzo 10:00
CitySakhir Racezo 16:00
'); }), test('Calling render with hass and sensor when season ended', () => { hassEntity.attributes['next_race'] = null; diff --git a/tests/utils/getCountryFlagUrl.test.ts b/tests/utils/getCountryFlagUrl.test.ts index 1370692..d24cc3d 100644 --- a/tests/utils/getCountryFlagUrl.test.ts +++ b/tests/utils/getCountryFlagUrl.test.ts @@ -2,16 +2,15 @@ import { getCountryFlagUrl } from '../../src/utils'; describe('Testing util file function getCountryFlagUrl', () => { test('Passing Japan should return expected flag url', () => { - expect(getCountryFlagUrl('Japan')).toBe('https://www.countries-ofthe-world.com/flags-normal/flag-of-Japan.png') + expect(getCountryFlagUrl('Japan')).toBe('https://flagcdn.com/w40/japan.png') }), test('Passing USA should return expected flag url', () => { - expect(getCountryFlagUrl('USA')).toBe('https://www.countries-ofthe-world.com/flags-normal/flag-of-United-States-of-America.png') + expect(getCountryFlagUrl('USA')).toBe('https://flagcdn.com/w40/us.png') }), test('Passing UAE should return expected flag url', () => { - expect(getCountryFlagUrl('UAE')).toBe('https://www.countries-ofthe-world.com/flags-normal/flag-of-United-Arab-Emirates.png') + expect(getCountryFlagUrl('UAE')).toBe('https://flagcdn.com/w40/ae.png') }), test('Passing Saudi Arabia should return expected flag url', () => { - expect(getCountryFlagUrl('Saudi-Arabia')).toBe('https://www.countries-ofthe-world.com/flags-normal/flag-of-Saudi-Arabia.png') + expect(getCountryFlagUrl('Saudi-Arabia')).toBe('https://flagcdn.com/w40/saudi-arabia.png') }) -}) - +}) \ No newline at end of file