You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					22 lines
				
				805 B
			
		
		
			
		
	
	
					22 lines
				
				805 B
			| 
								 
											3 years ago
										 
									 | 
							
								import { createCastError } from '../../src/utils/create-cast-error'
							 | 
						||
| 
								 | 
							
								import { SAMPLE_CAST_ERROR } from '../fixtures/mongoose-cast-error'
							 | 
						||
| 
								 | 
							
								import { SAMPLE_CAST_ARRAY_ERROR } from '../fixtures/mongoose-cast-array-error'
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								describe('createCastError', () => {
							 | 
						||
| 
								 | 
							
								  describe('throwin cast error on update after one key has error', () => {
							 | 
						||
| 
								 | 
							
								    it('has error for nested "parent.age" (errorKey) field', () => {
							 | 
						||
| 
								 | 
							
								      const error = createCastError(SAMPLE_CAST_ERROR)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      expect(error.propertyErrors.age.type).toEqual('Number')
							 | 
						||
| 
								 | 
							
								    })
							 | 
						||
| 
								 | 
							
								  })
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  describe('throwing cast error on update when one array field has error', () => {
							 | 
						||
| 
								 | 
							
								    it('throws an error for root field', () => {
							 | 
						||
| 
								 | 
							
								      const error = createCastError(SAMPLE_CAST_ARRAY_ERROR)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      expect(error.propertyErrors.authors.type).toEqual('ObjectId')
							 | 
						||
| 
								 | 
							
								    })
							 | 
						||
| 
								 | 
							
								  })
							 | 
						||
| 
								 | 
							
								})
							 |