Skip to content

Commit

Permalink
Merge c96c925 into 9cca493
Browse files Browse the repository at this point in the history
  • Loading branch information
marcokreeft87 authored Jan 1, 2023
2 parents 9cca493 + c96c925 commit ff48485
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions formulaone-card.js

Large diffs are not rendered by default.

Binary file modified formulaone-card.js.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "formulaone-card",
"version": "0.2.2",
"version": "0.2.3",
"description": "Frontend card for hass-formulaoneapi",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ export const getCountryFlagByNationality = (nationality: string) => {
}

export const getCountryFlagByName = (countryName: string) => {
const exceptions = [{ countryCode: 'USA', corrected: 'United States of America'}, { countryCode: 'UAE', corrected: 'United Arab Emirates'}];

const exception = exceptions.filter(exception => exception.countryCode == countryName);
if(exception.length > 0)
{
countryName = exception[0].corrected;
}

const country = countries.filter(x => x.Country === countryName)[0];

return getCountryFlagUrl(country.Code);
Expand Down
6 changes: 6 additions & 0 deletions tests/utils/getCountryFlagUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ describe('Testing util file function getCountryFlagUrl', () => {
test('Passing UAE should return expected flag url', () => {
expect(getCountryFlagUrl('UAE')).toBe('https://flagcdn.com/w40/ae.png')
}),
test('Passing USA should return expected flag url', () => {
expect(getCountryFlagByName('USA')).toBe('https://flagcdn.com/w40/us.png')
}),
test('Passing UAE should return expected flag url', () => {
expect(getCountryFlagByName('UAE')).toBe('https://flagcdn.com/w40/ae.png')
}),
test('Passing Saudi Arabia should return expected flag url', () => {
expect(getCountryFlagUrl('Saudi-Arabia')).toBe('https://flagcdn.com/w40/saudi-arabia.png')
})
Expand Down

0 comments on commit ff48485

Please sign in to comment.