@signatu/common-lib
Version:
Common Javascript/Typescript library for Signatu
54 lines • 2.19 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("../index");
describe('Country', function () {
var country;
beforeEach(function () {
});
describe('country tests', function () {
it('parses 2-letter codes', function () {
var country = new index_1.Country('bg');
expect(country.name).toEqual('Bulgaria');
country = new index_1.Country('No');
expect(country.name).toEqual('Norway');
});
it('parses full country names', function () {
var country = new index_1.Country('bulgAria');
expect(country.name).toEqual('Bulgaria');
country = new index_1.Country('norway');
expect(country.name).toEqual('Norway');
});
it('does not recognize meta-country names', function () {
expect(function () { new index_1.Country('EU'); }).toThrow('Unknown country code: EU');
});
it('returns all supported countries', function () {
var supportedCountries = index_1.Country.supportedCountries;
expect(supportedCountries.length).toBeGreaterThan(34);
});
it('returns all countries', function () {
var supportedCountries = index_1.Country.allCountries;
expect(supportedCountries.length).toEqual(249);
});
});
describe('country serialization', function () {
it('serializes', function () {
var country = new index_1.Country('bg');
var countryJSON = country.toJSON();
expect(countryJSON).toEqual('BG');
});
it('de-serializes', function () {
var country = index_1.Country.fromJSON('BG');
expect(country.name).toEqual('Bulgaria');
});
});
describe('deserializes', function () {
it('correctly', function () {
var country = new index_1.Country('bg');
var s = JSON.stringify(country);
var json = JSON.parse(s);
var parsed = index_1.Country.fromJSON(json);
expect(country).toEqual(parsed);
});
});
});
//# sourceMappingURL=country.test.js.map
;