generated from codevor/js-library-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
260 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export function sum(x, y) { | ||
return x + y; | ||
} | ||
export * from './validators'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export { default as isArray } from './is-array'; | ||
export { default as isBoolean } from './is-boolean'; | ||
export { default as isFunction } from './is-function'; | ||
export { default as isObject } from './is-object'; | ||
export { default as isString } from './is-string'; | ||
export { default as isUndefined } from './is-undefined'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const isArray = value => Array.isArray(value); | ||
|
||
export default isArray; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const isBoolean = value => typeof value === 'boolean'; | ||
|
||
export default isBoolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const isFunction = value => typeof value === "function"; | ||
|
||
export default isFunction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const isObject = value => typeof value === "object"; | ||
|
||
export default isObject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const isString = value => typeof value === "string"; | ||
|
||
export default isString; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const isUndefined = value => typeof value === "undefined"; | ||
|
||
export default isUndefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { isArray } from '../src'; | ||
|
||
describe('isArray()', () => { | ||
const anonymousFunction = () => {}; | ||
function namedFunction() {} | ||
const emptyArrayValue = []; | ||
const arrayValue = [2, 8, 'test']; | ||
const stringValue = 'This is a string'; | ||
const booleanValue = true; | ||
|
||
test('empty array should be valid', () => { | ||
expect(isArray(emptyArrayValue)).toBeTruthy(); | ||
}); | ||
|
||
test('correct array, not empty should be valid', () => { | ||
expect(isArray(arrayValue)).toBeTruthy(); | ||
}); | ||
|
||
test('anonymous function should be invalid', () => { | ||
expect(isArray(anonymousFunction)).toBeFalsy(); | ||
}); | ||
|
||
test('named function should be invalid', () => { | ||
expect(isArray(namedFunction)).toBeFalsy(); | ||
}); | ||
|
||
test('non array (string value) should be invalid', () => { | ||
expect(isArray(stringValue)).toBeFalsy(); | ||
}); | ||
|
||
test('non array (boolean value) should be invalid', () => { | ||
expect(isArray(booleanValue)).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { isBoolean } from '../src'; | ||
|
||
describe('isBoolean()', () => { | ||
const anonymousFunction = () => {}; | ||
function namedFunction() {}; | ||
const booleanValue = true; | ||
const arrayValue = [4, true, 'test']; | ||
const stringValue = 'This is a string'; | ||
const numberValue = 3; | ||
|
||
test('boolean value should be valid', () => { | ||
expect(isBoolean(booleanValue)).toBeTruthy(); | ||
}); | ||
|
||
test('anonymous function value should be invalid', () => { | ||
expect(isBoolean(anonymousFunction)).toBeFalsy(); | ||
}); | ||
|
||
test('named function value should be invalid', () => { | ||
expect(isBoolean(namedFunction)).toBeFalsy(); | ||
}); | ||
|
||
test('array value should be invalid', () => { | ||
expect(isBoolean(arrayValue)).toBeFalsy(); | ||
}); | ||
|
||
test('string value should be invalid', () => { | ||
expect(isBoolean(stringValue)).toBeFalsy(); | ||
}); | ||
|
||
test('number value should be invalid', () => { | ||
expect(isBoolean(numberValue)).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { isFunction } from '../src'; | ||
|
||
describe('isFunction()', () => { | ||
const anonymousFunction = () => {}; | ||
function namedFunction() {} | ||
const booleanValue = true; | ||
const arrayValue = [4, true, 'test']; | ||
const stringValue = 'This is a string'; | ||
const numberValue = 3; | ||
|
||
test('anonymous function should be valid', () => { | ||
expect(isFunction(anonymousFunction)).toBeTruthy(); | ||
}); | ||
|
||
test('named function should be valid', () => { | ||
expect(isFunction(namedFunction)).toBeTruthy(); | ||
}); | ||
|
||
test('boolean value should be invalid', () => { | ||
expect(isFunction(booleanValue)).toBeFalsy(); | ||
}); | ||
|
||
test('array value should be invalid', () => { | ||
expect(isFunction(arrayValue)).toBeFalsy(); | ||
}); | ||
|
||
test('string value should be invalid', () => { | ||
expect(isFunction(stringValue)).toBeFalsy(); | ||
}); | ||
|
||
test('number value should be invalid', () => { | ||
expect(isFunction(numberValue)).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { isObject } from '../src'; | ||
|
||
describe('isObject()', () => { | ||
const anonymousFunction = () => {}; | ||
function namedFunction() {} | ||
const objectValue = { test: 1 }; | ||
const arrayValue = []; | ||
const numberValue = 3; | ||
const booleanValue = true; | ||
|
||
test('object value should be valid', () => { | ||
expect(isObject(objectValue)).toBeTruthy(); | ||
}); | ||
|
||
test('array value should be valid(arrays are objects!!)', () => { | ||
expect(isObject(arrayValue)).toBeTruthy(); | ||
}); | ||
|
||
test('anonymous function value should be invalid', () => { | ||
expect(isObject(anonymousFunction)).toBeFalsy(); | ||
}); | ||
|
||
test('named function value should be invalid', () => { | ||
expect(isObject(namedFunction)).toBeFalsy(); | ||
}); | ||
|
||
test('number value should be invalid', () => { | ||
expect(isObject(numberValue)).toBeFalsy(); | ||
}); | ||
|
||
test('boolean value should be invalid', () => { | ||
expect(isObject(booleanValue)).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { isString } from '../src'; | ||
|
||
describe('isString()', () => { | ||
const anonymousFunction = () => {}; | ||
function namedFunction() {} | ||
const objectValue = { test: 1 }; | ||
const arrayValue = []; | ||
const stringValue = 'defined'; | ||
const numberValue = 3; | ||
const booleanValue = true; | ||
|
||
test('string value should be valid', () => { | ||
expect(isString(stringValue)).toBeTruthy(); | ||
}); | ||
|
||
test('anonymous function should be invalid', () => { | ||
expect(isString(anonymousFunction)).toBeFalsy(); | ||
}); | ||
|
||
test('named function should be invalid', () => { | ||
expect(isString(namedFunction)).toBeFalsy(); | ||
}); | ||
|
||
test('object value should be invalid', () => { | ||
expect(isString(objectValue)).toBeFalsy(); | ||
}); | ||
|
||
test('array value should be invalid', () => { | ||
expect(isString(arrayValue)).toBeFalsy(); | ||
}); | ||
|
||
test('number value should be invalid', () => { | ||
expect(isString(numberValue)).toBeFalsy(); | ||
}); | ||
|
||
test('boolean value should be invalid', () => { | ||
expect(isString(booleanValue)).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { isUndefined } from '../src'; | ||
|
||
describe('isUndefined()', () => { | ||
const definedValue = 2; | ||
const notDefinedValue = undefined; | ||
|
||
test('defined value should be invalid', () => { | ||
expect(isUndefined(definedValue)).toBeFalsy(); | ||
}); | ||
|
||
test('non defined should be valid', () => { | ||
expect(isUndefined(notDefinedValue)).toBeTruthy(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters