Fixed broken tests

This commit is contained in:
Angelos Chalaris
2018-10-31 19:29:49 +02:00
parent 90b830bc0d
commit 231941fed1
2 changed files with 52 additions and 2 deletions

View File

@ -19,8 +19,10 @@ test('Returns the longest array', () => {
test('Returns the longest object when comparing arrays and strings', () => {
expect(longestItem([1, 2, 3], 'foobar')).toEqual('foobar');
});
test('Returns undefined without any input', () => {
expect(longestItem()).toEqual(undefined);
test('Returns TypeError without any input', () => {
expect(() => {
longestItem();
}).toThrow(TypeError);
});
test('Returns first found of all similar', () => {
expect(longestItem('a', 'b', 'c')).toEqual('a');

48
test/toTitleCase.test.js Normal file
View File

@ -0,0 +1,48 @@
const expect = require('expect');
const {toTitleCase} = require('./_30s.js');
test('toTitleCase is a Function', () => {
expect(toTitleCase).toBeInstanceOf(Function);
});
test("toTitleCase('some_database_field_name') returns Some Database Field Name", () => {
expect(toTitleCase('some_database_field_name')).toBe('Some Database Field Name');
});
test("toTitleCase('Some label that needs to be titled') returns Some Label That Needs To Be Titled", () => {
expect(toTitleCase('Some label that needs to be titled')).toBe(
'Some Label That Needs To Be Titled'
);
});
test("toTitleCase('some-javaScript-property') return Some Java Script Property", () => {
expect(toTitleCase('some-javaScript-property')).toBe('Some Java Script Property');
});
test("toTitleCase('some-mixed_string with spaces_underscores-and-hyphens') returns Some Mixed String With Spaces Underscores And Hyphens", () => {
expect(toTitleCase('some-mixed_string with spaces_underscores-and-hyphens')).toBe(
'Some Mixed String With Spaces Underscores And Hyphens'
);
});
test('toTitleCase() throws a error', () => {
expect(() => {
toTitleCase();
}).toThrow();
});
test('toTitleCase([]) throws a error', () => {
expect(() => {
toCamelCase([]);
}).toThrow();
});
test('toCamelCase({}) throws a error', () => {
expect(() => {
toTitleCase({});
}).toThrow();
});
test('toTitleCase(123) throws a error', () => {
expect(() => {
toTitleCase(123);
}).toThrow();
});
let start = new Date().getTime();
toTitleCase('some-mixed_string with spaces_underscores-and-hyphens');
let end = new Date().getTime();
test('toTitleCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run', () => {
expect(end - start < 2000).toBeTruthy();
});