Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
dd3e1c9f
Commit
dd3e1c9f
authored
Nov 05, 2019
by
Ben Wheeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update country data test
parent
7b69935d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
test/unit/lib/country-data.test.js
test/unit/lib/country-data.test.js
+21
-11
No files found.
test/unit/lib/country-data.test.js
View file @
dd3e1c9f
...
@@ -3,7 +3,8 @@ const {
...
@@ -3,7 +3,8 @@ const {
countryOptions
,
countryOptions
,
lookupCountryInfo
,
lookupCountryInfo
,
dupeCommonCountries
,
dupeCommonCountries
,
registrationCountryOptions
,
registrationCountryCodeOptions
,
registrationCountryNameOptions
,
subdivisionOptions
subdivisionOptions
}
=
require
(
'
../../../src/lib/country-data
'
);
}
=
require
(
'
../../../src/lib/country-data
'
);
...
@@ -74,32 +75,41 @@ describe('unit test lib/country-data.js', () => {
...
@@ -74,32 +75,41 @@ describe('unit test lib/country-data.js', () => {
expect
(
ukItems
.
length
).
toEqual
(
2
);
expect
(
ukItems
.
length
).
toEqual
(
2
);
});
});
test
(
'
registrationCountryOptions object uses country names for both option label and option value
'
,
()
=>
{
test
(
'
registrationCountry
Name
Options object uses country names for both option label and option value
'
,
()
=>
{
expect
(
typeof
registrationCountryOptions
).
toBe
(
'
object
'
);
expect
(
typeof
registrationCountry
Name
Options
).
toBe
(
'
object
'
);
// test that there is one option with label and value === 'Brazil'
// test that there is one option with label and value === 'Brazil'
const
brazilOptions
=
registrationCountryOptions
.
reduce
((
acc
,
thisCountry
)
=>
(
const
brazilOptions
=
registrationCountry
Name
Options
.
reduce
((
acc
,
thisCountry
)
=>
(
(
thisCountry
.
value
===
'
Brazil
'
&&
thisCountry
.
label
===
'
Brazil
'
)
?
[...
acc
,
thisCountry
]
:
acc
(
thisCountry
.
value
===
'
Brazil
'
&&
thisCountry
.
label
===
'
Brazil
'
)
?
[...
acc
,
thisCountry
]
:
acc
),
[]);
),
[]);
expect
(
brazilOptions
.
length
).
toEqual
(
1
);
expect
(
brazilOptions
.
length
).
toEqual
(
1
);
});
});
test
(
'
registrationCountryOptions object places USA and UK at start, with display name versions
'
,
()
=>
{
test
(
'
registrationCountryCodeOptions object uses country codes for option value
'
,
()
=>
{
expect
(
typeof
registrationCountryOptions
).
toBe
(
'
object
'
);
expect
(
typeof
registrationCountryCodeOptions
).
toBe
(
'
object
'
);
// test that there is one option with label and value === 'Brazil'
const
brazilOptions
=
registrationCountryCodeOptions
.
reduce
((
acc
,
thisCountry
)
=>
(
(
thisCountry
.
value
===
'
br
'
&&
thisCountry
.
label
===
'
Brazil
'
)
?
[...
acc
,
thisCountry
]
:
acc
),
[]);
expect
(
brazilOptions
.
length
).
toEqual
(
1
);
});
test
(
'
registrationCountryNameOptions object places USA and UK at start, with display name versions
'
,
()
=>
{
expect
(
typeof
registrationCountryNameOptions
).
toBe
(
'
object
'
);
const
numCountries
=
countryInfo
.
length
;
const
numCountries
=
countryInfo
.
length
;
// test that the two entries have been added to the start of the array, and that
// test that the two entries have been added to the start of the array, and that
// the name of the USA includes "America"
// the name of the USA includes "America"
expect
(
registrationCountryOptions
.
length
).
toEqual
(
numCountries
+
2
);
expect
(
registrationCountry
Name
Options
.
length
).
toEqual
(
numCountries
+
2
);
expect
(
registrationCountryOptions
[
0
]).
toEqual
({
value
:
'
United States
'
,
label
:
'
United States of America
'
});
expect
(
registrationCountry
Name
Options
[
0
]).
toEqual
({
value
:
'
United States
'
,
label
:
'
United States of America
'
});
expect
(
registrationCountryOptions
[
1
]).
toEqual
({
value
:
'
United Kingdom
'
,
label
:
'
United Kingdom
'
});
expect
(
registrationCountry
Name
Options
[
1
]).
toEqual
({
value
:
'
United Kingdom
'
,
label
:
'
United Kingdom
'
});
// test that there are now two entries for USA
// test that there are now two entries for USA
const
usaOptions
=
registrationCountryOptions
.
reduce
((
acc
,
thisCountry
)
=>
(
const
usaOptions
=
registrationCountry
Name
Options
.
reduce
((
acc
,
thisCountry
)
=>
(
thisCountry
.
value
===
'
United States
'
?
[...
acc
,
thisCountry
]
:
acc
thisCountry
.
value
===
'
United States
'
?
[...
acc
,
thisCountry
]
:
acc
),
[]);
),
[]);
expect
(
usaOptions
.
length
).
toEqual
(
2
);
expect
(
usaOptions
.
length
).
toEqual
(
2
);
// test that there are now two entries for UK
// test that there are now two entries for UK
const
ukOptions
=
registrationCountryOptions
.
reduce
((
acc
,
thisCountry
)
=>
(
const
ukOptions
=
registrationCountry
Name
Options
.
reduce
((
acc
,
thisCountry
)
=>
(
thisCountry
.
value
===
'
United Kingdom
'
?
[...
acc
,
thisCountry
]
:
acc
thisCountry
.
value
===
'
United Kingdom
'
?
[...
acc
,
thisCountry
]
:
acc
),
[]);
),
[]);
expect
(
ukOptions
.
length
).
toEqual
(
2
);
expect
(
ukOptions
.
length
).
toEqual
(
2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment