Skip to content

Commit

Permalink
Merge pull request #25 from P3trur0/missing-flags
Browse files Browse the repository at this point in the history
version 2.0.0
  • Loading branch information
p3trur0 authored Apr 11, 2020
2 parents ea04981 + 5676463 commit 19f8813
Show file tree
Hide file tree
Showing 9 changed files with 5,131 additions and 4,440 deletions.
513 changes: 268 additions & 245 deletions README.md

Large diffs are not rendered by default.

41 changes: 29 additions & 12 deletions __tests__/CountryFlag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,11 @@ const buildNormalFlag = (country) => {
}
}

const buildFlag = (country, size) => {
const buildFlag = (country, size, rounded) => {
return {
country: country,
size: size
size: size,
rounded: rounded || false
}
}

Expand Down Expand Up @@ -295,37 +296,53 @@ describe('CountryFlag', () => {
const flag = shallowMount(CountryFlag, {
propsData: buildNormalFlag('it')
});
expect(flag.attributes('class')).toBe('flag flag-it normal-flag');
expect(flag.attributes('class')).toBe('f f-it normal-flag');
})

test('big size of country-flag should return a big flag', () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag('se', 'big')
});
expect(flag.attributes('class')).toBe('flag flag-se big-flag');
expect(flag.attributes('class')).toBe('f f-se big-flag');
})

test("big size of rounded country-flag should return a rounded big flag", () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag("se", "big", true)
});
expect(flag.attributes("class")).toBe(
"f f-se rounded big-flag"
);
});

test('small size of country-flag should return a small flag', () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag('se', 'small')
});
expect(flag.attributes('class')).toBe('flag flag-se small-flag');
expect(flag.attributes('class')).toBe('f f-se small-flag');
})

test('normal size of country-flag should return a normal flag', () => {
test("normal size of country-flag should return a normal flag", () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag("se", "normal")
});
expect(flag.attributes("class")).toBe("f f-se normal-flag");
}),

test("[CAPITAL LETTER lowercase conversion] normal size of country-flag should return a normal flag", () => {
const flag = shallowMount(CountryFlag, {
propsData: buildFlag('se', 'normal')
propsData: buildFlag("SE", "normal")
});
expect(flag.attributes('class')).toBe('flag flag-se normal-flag');
})
expect(flag.attributes("class")).toBe("f f-se normal-flag");
});
});

describe('CountryFlag ISO-3166-1 alpha-3 support', () => {
test('it should return a flag also for three characters country identifier', () => {
const flag = shallowMount(CountryFlag, {
propsData: buildNormalFlag(convertToISOAlphaThree('it'))
});
expect(flag.attributes('class')).toBe('flag flag-ita normal-flag');
expect(flag.attributes('class')).toBe('f f-ita normal-flag');
})

test('it should map both two and three characters for all the countries', () => {
Expand All @@ -342,8 +359,8 @@ describe('CountryFlag', () => {
propsData: buildNormalFlag(threeCharsIdentifier)
});

expect(flagTwo.attributes('class')).toBe('flag flag-' + twoCharsIdentifier + ' normal-flag');
expect(flagThree.attributes('class')).toBe('flag flag-' + threeCharsIdentifier + ' normal-flag');
expect(flagTwo.attributes('class')).toBe('f f-' + twoCharsIdentifier + ' normal-flag');
expect(flagThree.attributes('class')).toBe('f f-' + threeCharsIdentifier + ' normal-flag');
}
}
})
Expand Down
Loading

0 comments on commit 19f8813

Please sign in to comment.