This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
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
7 changed files
with
23 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
import { $at } from './type-collector-snippet'; | ||
import { $_$twiz } from './type-collector-snippet'; | ||
|
||
describe('type-collector', () => { | ||
describe('getTypeName', () => { | ||
it('should should return "null" for null', () => { | ||
expect($at.typeName(null)).toBe('null'); | ||
expect($_$twiz.typeName(null)).toBe('null'); | ||
}); | ||
|
||
it('should should return "undefined" for undefined', () => { | ||
expect($at.typeName(undefined)).toBe('undefined'); | ||
expect($_$twiz.typeName(undefined)).toBe('undefined'); | ||
}); | ||
|
||
it('should should return "boolean" for a true', () => { | ||
expect($at.typeName(true)).toBe('boolean'); | ||
expect($_$twiz.typeName(true)).toBe('boolean'); | ||
}); | ||
|
||
it('should should return "number" for a NaN', () => { | ||
// Not-a-Number is a actually number. I know, this is funny. | ||
expect($at.typeName(NaN)).toBe('number'); | ||
expect($_$twiz.typeName(NaN)).toBe('number'); | ||
}); | ||
|
||
it('should should return "string" for a string', () => { | ||
expect($at.typeName('hello')).toBe('string'); | ||
expect($_$twiz.typeName('hello')).toBe('string'); | ||
}); | ||
|
||
it('should should return "Set" for a Set', () => { | ||
expect($at.typeName(new Set())).toBe('Set'); | ||
expect($_$twiz.typeName(new Set())).toBe('Set'); | ||
}); | ||
|
||
it('should should return null for an empty array', () => { | ||
expect($at.typeName([])).toBe(null); | ||
expect($_$twiz.typeName([])).toBe(null); | ||
}); | ||
|
||
it('should should return "string[]" for array of strings', () => { | ||
expect($at.typeName(['foo', 'bar'])).toBe('string[]'); | ||
expect($_$twiz.typeName(['foo', 'bar'])).toBe('string[]'); | ||
}); | ||
|
||
it('should should return "Array<number|string>" for mixed array of strings and numbers', () => { | ||
expect($at.typeName(['foo', 15])).toBe('Array<number|string>'); | ||
expect($_$twiz.typeName(['foo', 15])).toBe('Array<number|string>'); | ||
}); | ||
|
||
it('should should return "string[][]" for array of string arrays', () => { | ||
expect($at.typeName([['foo'], [], ['bar', 'baz']])).toBe('string[][]'); | ||
expect($_$twiz.typeName([['foo'], [], ['bar', 'baz']])).toBe('string[][]'); | ||
}); | ||
|
||
it('should return "Function" for functions', () => { | ||
expect($at.typeName(() => 0)).toBe('Function'); | ||
expect($_$twiz.typeName(() => 0)).toBe('Function'); | ||
}); | ||
|
||
it('should throw a NestError in case of array has includes itself', () => { | ||
const a = []; | ||
a.push(a); | ||
expect(() => $at.typeName(a)).toThrowError('NestError'); | ||
expect(() => $_$twiz.typeName(a)).toThrowError('NestError'); | ||
}); | ||
}); | ||
}); |
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