cozy-client 46.11.0 → 47.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CozyClient.js +1 -1
- package/dist/models/{countries.js → country/countries.js} +180 -276
- package/dist/models/country/countries.spec.js +167 -0
- package/dist/models/country/locales/en.json +496 -0
- package/dist/models/country/locales/fr.json +496 -0
- package/dist/models/country/locales/index.js +41 -0
- package/dist/models/document/locales/index.js +3 -3
- package/dist/types.js +16 -0
- package/package.json +3 -3
- package/types/models/country/countries.d.ts +18 -0
- package/types/models/country/locales/index.d.ts +1 -0
- package/types/types.d.ts +36 -0
- package/dist/models/countries.spec.js +0 -18
- package/dist/models/document/emojiCountry.js +0 -36
- package/dist/models/document/emojiCountry.spec.js +0 -34
- package/types/models/countries.d.ts +0 -33
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { checkCountryCode } from './countries'
|
|
2
|
-
|
|
3
|
-
describe('checkCountryCode', () => {
|
|
4
|
-
it('should return true for valid country codes', () => {
|
|
5
|
-
expect(checkCountryCode('FR')).toBe(true)
|
|
6
|
-
expect(checkCountryCode('fr')).toBe(true)
|
|
7
|
-
expect(checkCountryCode('FRA')).toBe(true)
|
|
8
|
-
expect(checkCountryCode('fra')).toBe(true)
|
|
9
|
-
expect(checkCountryCode('US')).toBe(true)
|
|
10
|
-
expect(checkCountryCode('us')).toBe(true)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('should return false for invalid country codes', () => {
|
|
14
|
-
expect(checkCountryCode(undefined)).toBe(false)
|
|
15
|
-
expect(checkCountryCode(null)).toBe(false)
|
|
16
|
-
expect(checkCountryCode('')).toBe(false)
|
|
17
|
-
})
|
|
18
|
-
})
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.getEmojiByCountry = void 0;
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
|
-
var _logger = _interopRequireDefault(require("../../logger"));
|
|
13
|
-
|
|
14
|
-
// The offset between uppercase ASCII and regional indicator symbols
|
|
15
|
-
var UNICODE_OFFSET = 127397;
|
|
16
|
-
/**
|
|
17
|
-
* @param {string} countryCode - ISO 3166-1 alpha-2 (eg. fr, us, etc)
|
|
18
|
-
* @returns {string} - Emoji of country
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
var getEmojiByCountry = function getEmojiByCountry(countryCode) {
|
|
22
|
-
if (!countryCode) return null;
|
|
23
|
-
|
|
24
|
-
if (!/^[a-z]{2}$/i.test(countryCode)) {
|
|
25
|
-
_logger.default.error("Country argument must be an ISO 3166-1 alpha-2 string, but got '".concat(JSON.stringify(countryCode), "' instead."));
|
|
26
|
-
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var codePoints = (0, _toConsumableArray2.default)(countryCode.toUpperCase()).map(function (letter) {
|
|
31
|
-
return letter.codePointAt(0) + UNICODE_OFFSET;
|
|
32
|
-
});
|
|
33
|
-
return String.fromCodePoint.apply(String, (0, _toConsumableArray2.default)(codePoints));
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.getEmojiByCountry = getEmojiByCountry;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { getEmojiByCountry } from './emojiCountry'
|
|
2
|
-
import logger from '../../logger'
|
|
3
|
-
|
|
4
|
-
describe('getEmojiByCountry', () => {
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
jest.spyOn(logger, 'error').mockImplementation(() => jest.fn())
|
|
7
|
-
})
|
|
8
|
-
afterEach(() => {
|
|
9
|
-
logger.error.mockRestore()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('should return French flag', () => {
|
|
13
|
-
const res = getEmojiByCountry('fr')
|
|
14
|
-
|
|
15
|
-
expect(res).toBe('🇫🇷')
|
|
16
|
-
})
|
|
17
|
-
it('should return Belgian flag', () => {
|
|
18
|
-
const res = getEmojiByCountry('be')
|
|
19
|
-
|
|
20
|
-
expect(res).toBe('🇧🇪')
|
|
21
|
-
})
|
|
22
|
-
it('should return "null" if the country is not ISO 3166-1 alpha-2 string', () => {
|
|
23
|
-
const res = getEmojiByCountry('fra')
|
|
24
|
-
|
|
25
|
-
expect(logger.error).toHaveBeenCalledTimes(1)
|
|
26
|
-
expect(res).toBe(null)
|
|
27
|
-
})
|
|
28
|
-
it('should return "null" if the country is undefined', () => {
|
|
29
|
-
const res = getEmojiByCountry(undefined)
|
|
30
|
-
|
|
31
|
-
expect(logger.error).not.toHaveBeenCalled()
|
|
32
|
-
expect(res).toBe(null)
|
|
33
|
-
})
|
|
34
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} CountryISO
|
|
3
|
-
* @property {string} code2 - ISO 3166-1 alpha-2
|
|
4
|
-
* @property {string} code3 - ISO 3166-1 alpha-3
|
|
5
|
-
* @property {string} name - Country name
|
|
6
|
-
* @property {string} number - ISO 3166-1 numeric
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* List of countries with their ISO codes
|
|
10
|
-
*
|
|
11
|
-
* @constant
|
|
12
|
-
* @type {CountryISO[]}
|
|
13
|
-
*/
|
|
14
|
-
export const COUNTRIES_ISO: CountryISO[];
|
|
15
|
-
export function checkCountryCode(code: string): boolean;
|
|
16
|
-
export type CountryISO = {
|
|
17
|
-
/**
|
|
18
|
-
* - ISO 3166-1 alpha-2
|
|
19
|
-
*/
|
|
20
|
-
code2: string;
|
|
21
|
-
/**
|
|
22
|
-
* - ISO 3166-1 alpha-3
|
|
23
|
-
*/
|
|
24
|
-
code3: string;
|
|
25
|
-
/**
|
|
26
|
-
* - Country name
|
|
27
|
-
*/
|
|
28
|
-
name: string;
|
|
29
|
-
/**
|
|
30
|
-
* - ISO 3166-1 numeric
|
|
31
|
-
*/
|
|
32
|
-
number: string;
|
|
33
|
-
};
|