Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team committed Aug 23, 2024
1 parent 7ca6341 commit 6c1af4e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/unit/services/geoipservice.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ describe('GeoIPService', function () {

it('should handle empty responses', function () {
cityReader.getWithPrefixLength.mock.mockImplementationOnce(() => [{}, 0]);
ispReader.getWithPrefixLength.mock.mockImplementationOnce(() => [{}, 0]);
ispReader.getWithPrefixLength.mock.mockImplementationOnce(() => [null, 0]);
const actual = service.geolocate('1.2.3.4');
expect(actual).to.deep.equal(emptyGeoResponse);
});

// eslint-disable-next-line mocha/no-setup-in-describe
[
[cityResponseWithRepresentedCountry, geoResponseWithRepresentedCountry],
[cityResponseWithRegisteredCountry, geoResponseWithRegisteredCountry],
[cityResponseWithCountry, geoResponseWithCountry],
].forEach(([mock, expected]) => {
(
[
[cityResponseWithRepresentedCountry, geoResponseWithRepresentedCountry],
[cityResponseWithRegisteredCountry, geoResponseWithRegisteredCountry],
[cityResponseWithCountry, geoResponseWithCountry],
] as const
).forEach(([mock, expected]) => {
it('should try records in the defined order', function () {
cityReader.getWithPrefixLength.mock.mockImplementationOnce(() => [mock, 32]);
cityReader.getWithPrefixLength.mock.mockImplementationOnce(() => [mock, 32]); // NOSONAR
const actual = service.geolocate('1.2.3.4');
expect(actual).to.deep.equal(expected);
});
Expand Down

0 comments on commit 6c1af4e

Please sign in to comment.