mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 18:08:11 +00:00 
			
		
		
		
	mock useIntl methods to solve issue with the unicode space character in the snapshot tests
This commit is contained in:
		
							parent
							
								
									d1cb57f422
								
							
						
					
					
						commit
						356c13e397
					
				| @ -37,6 +37,21 @@ jest.spyOn(axiosInstance, 'get').mockResolvedValue({ | ||||
| 
 | ||||
| jest.spyOn(Date, 'now').mockImplementation(() => new Date('2015-10-01T08:00:00.000Z')); | ||||
| 
 | ||||
| jest.mock('react-intl', () => { | ||||
|   const reactIntl = jest.requireActual('react-intl'); | ||||
|   const intl = reactIntl.createIntl({ | ||||
|     locale: 'en', | ||||
|   }); | ||||
| 
 | ||||
|   intl.formatDate = jest.fn(() => '11/15/2021'); | ||||
|   intl.formatTime = jest.fn(() => '12:00 AM'); | ||||
| 
 | ||||
|   return { | ||||
|     ...reactIntl, | ||||
|     useIntl: () => intl, | ||||
|   }; | ||||
| }); | ||||
| 
 | ||||
| const client = new QueryClient({ | ||||
|   defaultOptions: { | ||||
|     queries: { | ||||
|  | ||||
| @ -13,6 +13,36 @@ import { createMemoryHistory } from 'history'; | ||||
| import qs from 'qs'; | ||||
| import FilterListURLQuery from '../index'; | ||||
| 
 | ||||
| jest.mock('react-intl', () => { | ||||
|   const reactIntl = jest.requireActual('react-intl'); | ||||
|   const intl = reactIntl.createIntl({ | ||||
|     locale: 'en', | ||||
|     messages: { | ||||
|       'components.FilterOptions.FILTER_TYPES.$eq': 'is', | ||||
|       'components.FilterOptions.FILTER_TYPES.$ne': 'is not', | ||||
|       'components.FilterOptions.FILTER_TYPES.$contains': 'contains (case sensitive)', | ||||
|       'components.FilterOptions.FILTER_TYPES.$notContains': 'does not contain (case sensitive)', | ||||
|       'components.FilterOptions.FILTER_TYPES.$gt': 'is greater than', | ||||
|       'components.FilterOptions.FILTER_TYPES.$gte': 'is greater than or equal to', | ||||
|       'components.FilterOptions.FILTER_TYPES.$lt': 'is lower than', | ||||
|       'components.FilterOptions.FILTER_TYPES.$lte': 'is lower than or equal to', | ||||
|       'components.FilterOptions.FILTER_TYPES.$startsWith': 'starts with', | ||||
|       'components.FilterOptions.FILTER_TYPES.$endsWith': 'ends with', | ||||
|       'components.FilterOptions.FILTER_TYPES.$null': 'is null', | ||||
|       'components.FilterOptions.FILTER_TYPES.$notNull': 'is not null', | ||||
|     }, | ||||
|     textComponent: 'span', | ||||
|   }); | ||||
| 
 | ||||
|   intl.formatDate = jest.fn(() => 'Wednesday, September 1, 2021'); | ||||
|   intl.formatTime = jest.fn(() => '12:45 AM'); | ||||
| 
 | ||||
|   return { | ||||
|     ...reactIntl, | ||||
|     useIntl: () => intl, | ||||
|   }; | ||||
| }); | ||||
| 
 | ||||
| const makeApp = (history, filtersSchema) => ( | ||||
|   <Router history={history}> | ||||
|     <ThemeProvider theme={lightTheme}> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Simone Taeggi
						Simone Taeggi