Files
30-seconds-of-code/test/toKebabCase.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

48 lines
1.8 KiB
JavaScript

const {toKebabCase} = require('./_30s.js');
test('toKebabCase is a Function', () => {
expect(toKebabCase).toBeInstanceOf(Function);
});
test("toKebabCase('camelCase') returns camel-case", () => {
expect(toKebabCase('camelCase')).toBe('camel-case');
});
test("toKebabCase('some text') returns some-text", () => {
expect(toKebabCase('some text')).toBe('some-text');
});
test("toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens", () => {
expect(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens')).toBe(
'some-mixed-string-with-spaces-underscores-and-hyphens'
);
});
test("toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html", () => {
expect(
toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML')
).toBe(
'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html'
);
});
test('toKebabCase() returns undefined', () => {
expect(toKebabCase()).toBe(undefined);
});
test('toKebabCase([]) throws an erro', () => {
expect(() => {
toKebabCase([]);
}).toThrow();
});
test('toKebabCase({}) throws an erro', () => {
expect(() => {
toKebabCase({});
}).toThrow();
});
test('toKebabCase(123) throws an erro', () => {
expect(() => {
toKebabCase(123);
}).toThrow();
});
let start = new Date().getTime();
toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML');
let end = new Date().getTime();
test('toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run', () => {
expect(end - start < 2000).toBeTruthy();
});