| 
									
										
										
										
											2022-09-01 19:26:54 +02:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-05 10:32:20 +02:00
										 |  |  | const { createStrapiInstance } = require('api-tests/strapi'); | 
					
						
							| 
									
										
										
										
											2023-10-09 10:54:13 +02:00
										 |  |  | const { isKnexQuery } = require('@strapi/database'); | 
					
						
							| 
									
										
										
										
											2022-09-01 19:26:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | let strapi; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe('knex', () => { | 
					
						
							|  |  |  |   beforeAll(async () => { | 
					
						
							|  |  |  |     strapi = await createStrapiInstance(); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   afterAll(async () => { | 
					
						
							|  |  |  |     await strapi.destroy(); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('isKnexQuery', () => { | 
					
						
							|  |  |  |     test('knex query: true', () => { | 
					
						
							|  |  |  |       const res = isKnexQuery(strapi.db.connection('strapi_core_store_settings')); | 
					
						
							|  |  |  |       expect(res).toBe(true); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     test('knex raw: true', () => { | 
					
						
							|  |  |  |       const res = isKnexQuery(strapi.db.connection.raw('SELECT * FROM strapi_core_store_settings')); | 
					
						
							|  |  |  |       expect(res).toBe(true); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     test.each([[''], [{}], [[]], [2], [new Date()]])('%s: false', (value) => { | 
					
						
							|  |  |  |       const res = isKnexQuery(value); | 
					
						
							|  |  |  |       expect(res).toBe(false); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); |