import {J} from "../../utils"; import { ControllerTestData, ControllerTestFunc, ControllerNetwork } from "../types"; export type uploadControllerTestData = { create$:ControllerTestData["uploads"]["create$"]; fetch$:ControllerTestData["uploads"]["fetch$"]; update$:ControllerTestData["uploads"]["update$"]; query$:ControllerTestData["uploads"]["query$"]; }; export const uploadControllerTestData:uploadControllerTestData = { create$:O => [ { body:{ filename:"rainbow.jpeg", size:1211, //title:"check it", bucket:"cctx-playground-uploads", path:"123467890987aaaaaaa", loc:{str:"123 Sesame St//Houston//Tx/77066/USA"}, desc:"profile-pic", type:"jpeg", owner:{model:"UserProfile",ref:O.jsons.profiles[0].id} }, appuser:{ name:O.users.jack, device:O.devices.jack, okto:"use-api", next:"123456", role:"GUEST" as any, } },{ body:{ filename:"rainbow-ext.jpeg", size:664, //title:"check it out again", bucket:"cctx-playground-uploads", path:"123467890987aaaaaa3", loc:{str:"123 Sesame St//Houston//Tx/77066/USA"}, desc:"profile-pic", type:"jpeg", owner:{model:"UserProfile",ref:O.jsons.profiles[0].id} }, appuser:{ name:O.users.jack, device:O.devices.jack, okto:"use-api", next:"123456", role:"GUEST" as any, } }, ], fetch$:O => [ { params:{id:O.jsons.uploads[0].id}, appuser:{ name:O.users.jack, device:O.devices.jack, okto:"use-api", next:"123456", role:"GUEST" as any, } },{ params:{filename:O.jsons.uploads[0].filename}, appuser:{ name:O.users.jack, device:O.devices.jack, okto:"use-api", next:"123456", role:"GUEST" as any, } } ], update$:O => [ { params:{id:O.jsons.uploads[0].id}, body:{$set:{status:{name:"Saved",time:new Date()}}}, appuser:{ name:O.users.jack, device:O.devices.jack, okto:"use-api", next:"123456", role:"GUEST" as any, } }, ], query$:O => [ { query:{query:{"owner.oid":O.users.john}}, appuser:{ name:O.users.jack, device:O.devices.jack, okto:"use-api", next:"123456", role:"GUEST" as any, } },{ query:{query:{"title":"check it"}}, appuser:{ name:O.users.jack, device:O.devices.jack, okto:"use-api", next:"123456", role:"GUEST" as any, } },{ query:{query:{"status?.name":"Novel" as any}}, appuser:{ name:O.users.jack, device:O.devices.jack, okto:"use-api", next:"123456", role:"GUEST" as any, } }, ], }; export type uploadControllerTests = { create$:ControllerTestFunc["uploads"]["create$"]; fetch$:ControllerTestFunc["uploads"]["fetch$"]; updateSetAndPush$:ControllerTestFunc["uploads"]["update$"]; updatePull$:ControllerTestFunc["uploads"]["update$"]; fetchFinal$:ControllerTestFunc["uploads"]["fetch$"]; query$:ControllerTestFunc["uploads"]["query$"]; }; export const uploadControllerTests:uploadControllerTests = { create$:async O => { const C = uploadControllerTestData.create$(O); for(let i = 0,l = C.length;i { const F = uploadControllerTestData.fetch$(O); for(let i = 0,l = F.length;i { const U = uploadControllerTestData.update$(O); for(let i = 0,l = U.length;i { const U = uploadControllerTestData.update$(O); for(let i = 0,l = U.length;i { const F = uploadControllerTestData.fetch$(O); const {data:o} = await O.controllers.uploads.fetch$(F[0]); J.is(o); J.not(o,null); J.is(o.status?.name.toLocaleUpperCase(),"SAVED"); }, query$:async O => { const Q = uploadControllerTestData.query$(O); for(let i = 0,l = Q.length;i J.desc("Uploads",() => { it("Create",async () => await uploadControllerTests.create$(O),1E9); it("Fetch",async () => await uploadControllerTests.fetch$(O),1E9); it("Update - Set & Push",async () => await uploadControllerTests.updateSetAndPush$(O),1E9); it("Update - Pull",async () => await uploadControllerTests.updatePull$(O),1E9); it("Fetch - Final Check",async () => await uploadControllerTests.fetchFinal$(O),1E9); it("Query",async () => await uploadControllerTests.query$(O),1E9); });