@@ -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' } ,
@@ -95,6 +99,8 @@ describe('Type System: Scalars', () => {
9599 serialize : passThroughFunc ,
96100 parseValue : passThroughFunc ,
97101 parseLiteral : passThroughFunc ,
102+ coerceOutputValue : passThroughFunc ,
103+ coerceInputValue : passThroughFunc ,
98104 coerceInputLiteral : passThroughFunc ,
99105 valueToLiteral : passThroughFunc ,
100106 extensions : { [ test ] : 'extension' } ,
@@ -110,6 +116,8 @@ describe('Type System: Scalars', () => {
110116
111117 expect ( scalar . serialize ) . to . equal ( identityFunc ) ;
112118 expect ( scalar . parseValue ) . to . equal ( identityFunc ) ;
119+ expect ( scalar . coerceOutputValue ) . to . equal ( identityFunc ) ;
120+ expect ( scalar . coerceInputValue ) . to . equal ( identityFunc ) ;
113121 expect ( scalar . parseLiteral ) . to . be . a ( 'function' ) ;
114122 /* default will be provided in v18 when parseLiteral is removed */
115123 // expect(scalar.coerceInputLiteral).to.be.a('function');
@@ -143,15 +151,15 @@ describe('Type System: Scalars', () => {
143151 ) ;
144152 } ) ;
145153
146- it ( 'rejects a Scalar type defining coerceInputLiteral but not parseValue ' , ( ) => {
154+ it ( 'rejects a Scalar type defining coerceInputLiteral but not coerceInputValue ' , ( ) => {
147155 expect (
148156 ( ) =>
149157 new GraphQLScalarType ( {
150158 name : 'SomeScalar' ,
151159 coerceInputLiteral : passThroughFunc ,
152160 } ) ,
153161 ) . to . throw (
154- 'SomeScalar must provide both "parseValue " and "coerceInputLiteral" functions.' ,
162+ 'SomeScalar must provide both "coerceInputValue " and "coerceInputLiteral" functions.' ,
155163 ) ;
156164 } ) ;
157165} ) ;
@@ -644,6 +652,30 @@ describe('Type System: Enums', () => {
644652 expect ( someEnum . toConfig ( ) ) . to . deep . equal ( someEnumConfig ) ;
645653 } ) ;
646654
655+ it ( 'can be coerced to an output value via serialize() method' , ( ) => {
656+ const someEnum = new GraphQLEnumType ( {
657+ name : 'SomeEnum' ,
658+ values : {
659+ FOO : {
660+ value : 'foo' ,
661+ } ,
662+ } ,
663+ } ) ;
664+ expect ( someEnum . serialize ( 'foo' ) ) . to . equal ( 'FOO' ) ;
665+ } ) ;
666+
667+ it ( 'can be coerced to an input value via parseValue() method' , ( ) => {
668+ const someEnum = new GraphQLEnumType ( {
669+ name : 'SomeEnum' ,
670+ values : {
671+ FOO : {
672+ value : 'foo' ,
673+ } ,
674+ } ,
675+ } ) ;
676+ expect ( someEnum . parseValue ( 'FOO' ) ) . to . equal ( 'foo' ) ;
677+ } ) ;
678+
647679 it ( 'defines an enum type with deprecated value' , ( ) => {
648680 const EnumTypeWithDeprecatedValue = new GraphQLEnumType ( {
649681 name : 'EnumWithDeprecatedValue' ,
0 commit comments