11/* eslint-env mocha */
22import expect from "expect"
33import { fromJS , OrderedMap } from "immutable"
4- import { mapToList , validateNumber , validateInteger , validateParam , validateFile , fromJSOrdered , getAcceptControllingResponse , createDeepLinkPath , escapeDeepLinkPath } from "core/utils"
4+ import { mapToList , validateDateTime , validateGuid , validateNumber , validateInteger , validateParam , validateFile , fromJSOrdered , getAcceptControllingResponse , createDeepLinkPath , escapeDeepLinkPath } from "core/utils"
55import win from "core/window"
66
77describe ( "utils" , function ( ) {
@@ -158,7 +158,7 @@ describe("utils", function() {
158158 } )
159159 } )
160160
161- describe ( "validateFile" , function ( ) {
161+ describe ( "validateFile" , function ( ) {
162162 let errorMessage = "Value must be a file"
163163
164164 it ( "validates against objects which are instances of 'File'" , function ( ) {
@@ -171,6 +171,34 @@ describe("utils", function() {
171171 } )
172172 } )
173173
174+ describe ( "validateDateTime" , function ( ) {
175+ let errorMessage = "Value must be a DateTime"
176+
177+ it ( "doesn't return for valid dates" , function ( ) {
178+ expect ( validateFile ( fileObj ) ) . toBeFalsy ( )
179+ expect ( validateFile ( null ) ) . toBeFalsy ( )
180+ } )
181+
182+ it ( "returns a message for invalid input'" , function ( ) {
183+ expect ( validateFile ( 1 ) ) . toEqual ( errorMessage )
184+ expect ( validateFile ( "string" ) ) . toEqual ( errorMessage )
185+ } )
186+ } )
187+
188+ describe ( "validateGuid" , function ( ) {
189+ let errorMessage = "Value must be a Guid"
190+
191+ it ( "doesn't return for valid guid" , function ( ) {
192+ expect ( validateGuid ( "8ce4811e-cec5-4a29-891a-15d1917153c1" ) ) . toBeFalsy ( )
193+ expect ( validateGuid ( "{8ce4811e-cec5-4a29-891a-15d1917153c1}" ) ) . toBeFalsy ( )
194+ } )
195+
196+ it ( "returns a message for invalid input'" , function ( ) {
197+ expect ( validateGuid ( 1 ) ) . toEqual ( errorMessage )
198+ expect ( validateGuid ( "string" ) ) . toEqual ( errorMessage )
199+ } )
200+ } )
201+
174202 describe ( "validateParam" , function ( ) {
175203 let param = null
176204 let result = null
0 commit comments