Files
30-seconds-of-code/test/pluralize.test.js
Christian C. Salvadó 83a6a6ea32 [ENHANCEMENT] Properly configure eslint to work with jest (#988)
* chore: make aware eslint that we use jest

By setting up the jest environment, we no longer need to declare the
'test' global in the configuration.

* chore: don't need to import expect, it's a jest environment global

* chore: don't need to import expect when creating undefined test
2019-06-18 08:34:45 +03:00

29 lines
870 B
JavaScript

const {pluralize} = require('./_30s.js');
test('pluralize is a Function', () => {
expect(pluralize).toBeInstanceOf(Function);
});
test('Produces the plural of the word', () => {
expect(pluralize(0, 'apple')).toBe('apples');
});
test('Produces the singular of the word', () => {
expect(pluralize(1, 'apple')).toBe('apple');
});
test('Produces the plural of the word', () => {
expect(pluralize(2, 'apple')).toBe('apples');
});
test('Produces the defined plural of the word', () => {
expect(pluralize(2, 'person', 'people')).toBe('people');
});
test('Produces the defined plural of the word', () => {
expect(pluralize(1, 'person', 'people')).toBe('person');
});
const PLURALS = {
person: 'people',
radius: 'radii'
};
const autoPluralize = pluralize(PLURALS);
test('Works with a dictionary', () => {
expect(autoPluralize(2, 'person')).toBe('people');
});