Test cleanup and fixes [s-t]

This commit is contained in:
Angelos Chalaris
2018-06-18 18:37:35 +03:00
parent 9c22d92c34
commit 46ad6c08b9
53 changed files with 286 additions and 409 deletions

View File

@ -1,34 +1,36 @@
const expect = require('expect');
const toKebabCase = require('./toKebabCase.js');
test('toKebabCase is a Function', () => {
test('toKebabCase is a Function', () => {
expect(toKebabCase).toBeInstanceOf(Function);
});
test('toKebabCase('camelCase') returns camel-case', () => {
expect(toKebabCase('camelCase')).toBe('camel-case')
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 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(\'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', () => {
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()
test('toKebabCase() returns undefined', () => {
expect(toKebabCase()).toBe(undefined)
});
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', () => {
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();
});