@@ -5,29 +5,25 @@ import { assertSuccess, assertFailure, assertStrictEqual, IntegerFromString, Num
55describe ( 'refinement' , ( ) => {
66 describe ( 'name' , ( ) => {
77 it ( 'should assign a default name' , ( ) => {
8- // tslint:disable-next-line: deprecation
98 const T = t . refinement ( t . number , ( n ) => n >= 0 )
109 assert . strictEqual ( T . name , '(number | <function1>)' )
1110 } )
1211
1312 it ( 'should accept a name' , ( ) => {
14- // tslint:disable-next-line: deprecation
1513 const T = t . refinement ( t . number , ( n ) => n >= 0 , 'T' )
1614 assert . strictEqual ( T . name , 'T' )
1715 } )
1816 } )
1917
2018 describe ( 'is' , ( ) => {
2119 it ( 'should check a isomorphic value' , ( ) => {
22- // tslint:disable-next-line: deprecation
2320 const T = t . Integer
2421 assert . strictEqual ( T . is ( 1.2 ) , false )
2522 assert . strictEqual ( T . is ( 'a' ) , false )
2623 assert . strictEqual ( T . is ( 1 ) , true )
2724 } )
2825
2926 it ( 'should check a prismatic value' , ( ) => {
30- // tslint:disable-next-line: deprecation
3127 const T = t . refinement ( NumberFromString , ( n ) => n % 1 === 0 )
3228 assert . strictEqual ( T . is ( 1.2 ) , false )
3329 assert . strictEqual ( T . is ( 'a' ) , false )
@@ -37,21 +33,22 @@ describe('refinement', () => {
3733
3834 describe ( 'decode' , ( ) => {
3935 it ( 'should succeed validating a valid value' , ( ) => {
40- // tslint:disable-next-line: deprecation
4136 const T = t . refinement ( t . number , ( n ) => n >= 0 )
4237 assertSuccess ( T . decode ( 0 ) )
4338 assertSuccess ( T . decode ( 1 ) )
4439 } )
4540
4641 it ( 'should return the same reference if validation succeeded' , ( ) => {
47- // tslint:disable-next-line: deprecation
48- const T = t . refinement ( t . Dictionary , ( ) => true )
42+ const T = t . refinement (
43+ // tslint:disable-next-line: deprecation
44+ t . Dictionary ,
45+ ( ) => true
46+ )
4947 const value = { }
5048 assertStrictEqual ( T . decode ( value ) , value )
5149 } )
5250
5351 it ( 'should fail validating an invalid value' , ( ) => {
54- // tslint:disable-next-line: deprecation
5552 const T = t . Integer
5653 assertFailure ( T , 'a' , [ 'Invalid value "a" supplied to : Integer' ] )
5754 assertFailure ( T , 1.2 , [ 'Invalid value 1.2 supplied to : Integer' ] )
@@ -66,13 +63,11 @@ describe('refinement', () => {
6663
6764 describe ( 'encode' , ( ) => {
6865 it ( 'should encode a prismatic value' , ( ) => {
69- // tslint:disable-next-line: deprecation
7066 const T = t . refinement ( t . array ( NumberFromString ) , ( ) => true )
7167 assert . deepStrictEqual ( T . encode ( [ 1 ] ) , [ '1' ] )
7268 } )
7369
7470 it ( 'should return the same reference while encoding' , ( ) => {
75- // tslint:disable-next-line: deprecation
7671 const T = t . refinement ( t . array ( t . number ) , ( ) => true )
7772 assert . strictEqual ( T . encode , t . identity )
7873 } )
0 commit comments