@@ -60,6 +60,8 @@ describe('Type System: Scalars', () => {
6060 serialize : someScalar . serialize ,
6161 parseValue : someScalar . parseValue ,
6262 parseLiteral : someScalar . parseLiteral ,
63+ coerceOutputValue : someScalar . coerceOutputValue ,
64+ coerceInputValue : someScalar . coerceInputValue ,
6365 coerceInputLiteral : undefined ,
6466 valueToLiteral : undefined ,
6567 extensions : { } ,
@@ -76,6 +78,8 @@ describe('Type System: Scalars', () => {
7678 serialize : passThroughFunc ,
7779 parseValue : passThroughFunc ,
7880 parseLiteral : passThroughFunc ,
81+ coerceOutputValue : passThroughFunc ,
82+ coerceInputValue : passThroughFunc ,
7983 coerceInputLiteral : passThroughFunc ,
8084 valueToLiteral : passThroughFunc ,
8185 extensions : { someExtension : 'extension' } ,
@@ -91,6 +95,8 @@ describe('Type System: Scalars', () => {
9195
9296 expect ( scalar . serialize ) . to . equal ( identityFunc ) ;
9397 expect ( scalar . parseValue ) . to . equal ( identityFunc ) ;
98+ expect ( scalar . coerceOutputValue ) . to . equal ( identityFunc ) ;
99+ expect ( scalar . coerceInputValue ) . to . equal ( identityFunc ) ;
94100 expect ( scalar . parseLiteral ) . to . be . a ( 'function' ) ;
95101 /* default will be provided in v18 when parseLiteral is removed */
96102 // expect(scalar.coerceInputLiteral).to.be.a('function');
@@ -124,15 +130,15 @@ describe('Type System: Scalars', () => {
124130 ) ;
125131 } ) ;
126132
127- it ( 'rejects a Scalar type defining coerceInputLiteral but not parseValue ' , ( ) => {
133+ it ( 'rejects a Scalar type defining coerceInputLiteral but not coerceInputValue ' , ( ) => {
128134 expect (
129135 ( ) =>
130136 new GraphQLScalarType ( {
131137 name : 'SomeScalar' ,
132138 coerceInputLiteral : passThroughFunc ,
133139 } ) ,
134140 ) . to . throw (
135- 'SomeScalar must provide both "parseValue " and "coerceInputLiteral" functions.' ,
141+ 'SomeScalar must provide both "coerceInputValue " and "coerceInputLiteral" functions.' ,
136142 ) ;
137143 } ) ;
138144} ) ;
@@ -625,6 +631,30 @@ describe('Type System: Enums', () => {
625631 expect ( someEnum . toConfig ( ) ) . to . deep . equal ( someEnumConfig ) ;
626632 } ) ;
627633
634+ it ( 'can be coerced to an output value via serialize() method' , ( ) => {
635+ const someEnum = new GraphQLEnumType ( {
636+ name : 'SomeEnum' ,
637+ values : {
638+ FOO : {
639+ value : 'foo' ,
640+ } ,
641+ } ,
642+ } ) ;
643+ expect ( someEnum . serialize ( 'foo' ) ) . to . equal ( 'FOO' ) ;
644+ } ) ;
645+
646+ it ( 'can be coerced to an input value via parseValue() method' , ( ) => {
647+ const someEnum = new GraphQLEnumType ( {
648+ name : 'SomeEnum' ,
649+ values : {
650+ FOO : {
651+ value : 'foo' ,
652+ } ,
653+ } ,
654+ } ) ;
655+ expect ( someEnum . parseValue ( 'FOO' ) ) . to . equal ( 'foo' ) ;
656+ } ) ;
657+
628658 it ( 'defines an enum type with deprecated value' , ( ) => {
629659 const EnumTypeWithDeprecatedValue = new GraphQLEnumType ( {
630660 name : 'EnumWithDeprecatedValue' ,
0 commit comments