-
-
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
6 changed files
with
47 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
interface Options { | ||
type: string; | ||
} | ||
export default function age(options?: Options): number; |
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,9 @@ | ||
import {expectType} from 'tsd'; | ||
import age from './index.js'; | ||
|
||
expectType<number>(age()); | ||
expectType<number>(age({type: 'child'})); | ||
expectType<number>(age({type: 'teen'})); | ||
expectType<number>(age({type: 'adult'})); | ||
expectType<number>(age({type: 'senior'})); | ||
expectType<number>(age({type: 'all'})); |
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,31 +1,31 @@ | ||
import age from './index.js'; | ||
import test from 'ava'; | ||
import age from './index.js'; | ||
|
||
test('age return type to be number', t => { | ||
t.is(typeof age(), 'number'); | ||
t.is(typeof age(), 'number'); | ||
}); | ||
|
||
test('age with type child less than 13 and more than -1', t => { | ||
t.true(age({type: 'child'}) < 13); | ||
t.true(age({type: 'child'}) > -1); | ||
t.true(age({type: 'child'}) < 13); | ||
t.true(age({type: 'child'}) > -1); | ||
}); | ||
|
||
test('age with type teen less than 20 and more than 12', t => { | ||
t.true(age({type: 'teen'}) < 20); | ||
t.true(age({type: 'teen'}) > 12); | ||
t.true(age({type: 'teen'}) < 20); | ||
t.true(age({type: 'teen'}) > 12); | ||
}); | ||
|
||
test('age with type adult less than 69 and more than 17', t => { | ||
t.true(age({type: 'adult'}) < 69); | ||
t.true(age({type: 'adult'}) > 17); | ||
t.true(age({type: 'adult'}) < 69); | ||
t.true(age({type: 'adult'}) > 17); | ||
}); | ||
|
||
test('age with type senior less than 101 and more than 64', t => { | ||
t.true(age({type: 'senior'}) < 101); | ||
t.true(age({type: 'senior'}) > 64); | ||
t.true(age({type: 'senior'}) < 101); | ||
t.true(age({type: 'senior'}) > 64); | ||
}); | ||
|
||
test('age with type all less than 101 and more than -1', t => { | ||
t.true(age({type: 'all'}) < 101); | ||
t.true(age({type: 'all'}) > -1); | ||
}); | ||
t.true(age({type: 'all'}) < 101); | ||
t.true(age({type: 'all'}) > -1); | ||
}); |