cartodb-4.42/lib/assets/test/spec/new-dashboard/unit/specs/utils/count-chars-array.spec.js
2024-04-06 05:25:13 +00:00

21 lines
769 B
JavaScript

import countCharsArray from 'new-dashboard/utils/count-chars-array';
describe('count-chars-array.js', () => {
it('count correctly the number of total chars in array', () => {
const array1 = null;
const array2 = [];
const array3 = ['abc'];
const array4 = ['abcd', '1234', 'my own test'];
expect(countCharsArray(array1, '')).toBe(0);
expect(countCharsArray(array1, '--')).toBe(0);
expect(countCharsArray(array2, '')).toBe(0);
expect(countCharsArray(array2, '...')).toBe(0);
expect(countCharsArray(array3)).toBe(3);
expect(countCharsArray(array3, '<--->')).toBe(3);
expect(countCharsArray(array4)).toBe(19);
expect(countCharsArray(array4, null)).toBe(19);
expect(countCharsArray(array4, ' && ')).toBe(27);
});
});