Skip to content

Commit

Permalink
Test: Unit tests for i18n #CCM-25
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Nov 19, 2021
1 parent 39468d1 commit d5bf67b
Show file tree
Hide file tree
Showing 9 changed files with 525 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"esbuild": "^0.13.6",
"husky": "^7.0.2",
"jest": "^27.3.1",
"jest-each": "^27.3.1",
"npm-run-all": "^4.1.5",
"postcss": "^8.3.6",
"postcss-cli": "^9.0.2",
Expand Down
33 changes: 33 additions & 0 deletions src/__tests__/utils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { addSeparators, pluralize } from '../utils';

describe('utils', () => {
describe('addSeparators', () => {
it('should return one word without separators', () => {
expect(addSeparators(['test'])).toBe('test');
});

it('should return two words separated with `and`', () => {
expect(addSeparators(['test1', 'test2'], 'and')).toBe('test1 and test2');
});

it('should return three words separated with comma and `and`', () => {
expect(addSeparators(['test1', 'test2', 'test3'], 'and')).toBe('test1, test2 and test3');
});

it('should return multiple words separated with comma and `and` as last separator', () => {
expect(addSeparators(['test1', 'test2', 'test3', 'test4', 'test5'], 'and')).toBe(
'test1, test2, test3, test4 and test5',
);
});
});

describe('pluralize', () => {
it('should return singular', () => {
expect(pluralize(1, 'test', 'tests')).toBe('test');
});

it('should return plural', () => {
expect(pluralize(2, 'test', 'tests')).toBe('tests');
});
});
});
Loading

0 comments on commit d5bf67b

Please sign in to comment.