Files
30-seconds-of-code/test/toKebabCase/toKebabCase.test.js
2018-06-18 16:34:04 +03:00

35 lines
1.8 KiB
JavaScript

const expect = require('expect');
const toKebabCase = require('./toKebabCase.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() return undefined', () => {
expect(toKebabCase(), undefined).toBe()
});
t.throws(() => toKebabCase([]), 'toKebabCase([]) throws an error');
t.throws(() => toKebabCase({}), 'toKebabCase({}) throws an error');
t.throws(() => toKebabCase(123), 'toKebabCase(123) throws an error');
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();
});