-
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
9 changed files
with
111 additions
and
21 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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import CustomType from './Custom'; | ||
|
||
export default class Undefined extends CustomType { | ||
/** | ||
* @param {any} value | ||
*/ | ||
parse(value) { | ||
return typeof value === '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,49 @@ | ||
import CustomType from './Custom'; | ||
import Undefined from './Undefined'; | ||
|
||
describe('Undefined', () => { | ||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
test('should extend `CustomType`', () => { | ||
expect(Undefined.prototype instanceof CustomType).toBe(true); | ||
}); | ||
|
||
test('should return `true` with value ``', () => { | ||
// @ts-ignore | ||
const output = new Undefined().parse(); | ||
|
||
expect(output).toBe(true); | ||
}); | ||
|
||
test('should return `true` with value `undefined`', () => { | ||
const output = new Undefined().parse(undefined); | ||
|
||
expect(output).toBe(true); | ||
}); | ||
|
||
test('should return `false` with value "1"', () => { | ||
const output = new Undefined().parse('1'); | ||
|
||
expect(output).toBe(false); | ||
}); | ||
|
||
test('should return `false` with value `0`', () => { | ||
const output = new Undefined().parse(0); | ||
|
||
expect(output).toBe(false); | ||
}); | ||
|
||
test('should return `false` with value `null`', () => { | ||
const output = new Undefined().parse(null); | ||
|
||
expect(output).toBe(false); | ||
}); | ||
|
||
test('should return `false` with value `NaN`', () => { | ||
const output = new Undefined().parse(NaN); | ||
|
||
expect(output).toBe(false); | ||
}); | ||
}); |
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,11 +1,13 @@ | ||
import Any from './Any'; | ||
import Or from './Or'; | ||
import Custom from './Custom'; | ||
import Undefined from './Undefined'; | ||
|
||
const types = { | ||
Any, | ||
Or, | ||
Custom, | ||
Undefined, | ||
}; | ||
|
||
export default types; |