11import {
22 assert ,
3+ assertArrayIncludes ,
34 assertEquals ,
4- assertArrayIncludes
55} from "https://deno.land/std@0.82.0/testing/asserts.ts" ;
66
77import { IQuery } from "./types.ts" ;
@@ -204,4 +204,108 @@ Deno.test("if 3 folders are returned when the where clause has isDirectory <> tr
204204 assertEquals ( result [ 0 ] . name , "root.txt" ) ;
205205 assertEquals ( result [ 0 ] . isDirectory , false ) ;
206206 assertEquals ( result [ 0 ] . isFile , true ) ;
207- } ) ;
207+ } ) ;
208+
209+ Deno . test ( "if 3 folders are returned when the where clause has isFile = true" , async ( ) => {
210+ const query : IQuery = {
211+ type : "select" ,
212+ fields : [ "*" ] ,
213+ from : "root" ,
214+ where : {
215+ conditions : [
216+ {
217+ left : "isFile" ,
218+ op : "Equal" ,
219+ right : "true" ,
220+ } ,
221+ ] ,
222+ } ,
223+ } ;
224+
225+ const result = await select ( query ) ;
226+
227+ assert ( result . length === 1 ) ;
228+ assertEquals ( result [ 0 ] . name , "root.txt" ) ;
229+ assertEquals ( result [ 0 ] . isDirectory , false ) ;
230+ assertEquals ( result [ 0 ] . isFile , true ) ;
231+ } ) ;
232+
233+ Deno . test ( "if the 'root.txt' is returned when the where clause has isFile = false" , async ( ) => {
234+ const query : IQuery = {
235+ type : "select" ,
236+ fields : [ "*" ] ,
237+ from : "root" ,
238+ where : {
239+ conditions : [
240+ {
241+ left : "isFile" ,
242+ op : "Equal" ,
243+ right : "false" ,
244+ } ,
245+ ] ,
246+ } ,
247+ } ;
248+
249+ const result = await select ( query ) ;
250+
251+ assert ( result . length === 3 ) ;
252+ const names = result . map ( ( i ) => i . name as string ) ;
253+ const expectedNames = [
254+ "test_folder_with_file" ,
255+ "test_folder_with_files" ,
256+ "test_folder_with_folder" ,
257+ ] ;
258+ assertArrayIncludes < string > ( names , expectedNames ) ;
259+ } ) ;
260+
261+ Deno . test ( "if the 'root.txt' is returned when the where clause has isFile <> false" , async ( ) => {
262+ const query : IQuery = {
263+ type : "select" ,
264+ fields : [ "*" ] ,
265+ from : "root" ,
266+ where : {
267+ conditions : [
268+ {
269+ left : "isFile" ,
270+ op : "Different" ,
271+ right : "false" ,
272+ } ,
273+ ] ,
274+ } ,
275+ } ;
276+
277+ const result = await select ( query ) ;
278+
279+ assert ( result . length === 1 ) ;
280+ assertEquals ( result [ 0 ] . name , "root.txt" ) ;
281+ assertEquals ( result [ 0 ] . isDirectory , false ) ;
282+ assertEquals ( result [ 0 ] . isFile , true ) ;
283+ } ) ;
284+
285+ Deno . test ( "if 3 folders are returned when the where clause has isFile <> true" , async ( ) => {
286+ const query : IQuery = {
287+ type : "select" ,
288+ fields : [ "*" ] ,
289+ from : "root" ,
290+ where : {
291+ conditions : [
292+ {
293+ left : "isFile" ,
294+ op : "Different" ,
295+ right : "true" ,
296+ } ,
297+ ] ,
298+ } ,
299+ } ;
300+
301+ const result = await select ( query ) ;
302+
303+ assert ( result . length === 3 ) ;
304+ const names = result . map ( ( i ) => i . name as string ) ;
305+ const expectedNames = [
306+ "test_folder_with_file" ,
307+ "test_folder_with_files" ,
308+ "test_folder_with_folder" ,
309+ ] ;
310+ assertArrayIncludes < string > ( names , expectedNames ) ;
311+ } ) ;
0 commit comments