import {J} from "../../utils"; import { FactoryTestData, FactoryTestFunc, FactoryNetwork } from "../types"; export type uploadFactoryTestData = { create:FactoryTestData["uploads"]["create"]; fetch:FactoryTestData["uploads"]["fetch"]; update:FactoryTestData["uploads"]["update"]; query:FactoryTestData["uploads"]["query"]; }; export const uploadFactoryTestData:uploadFactoryTestData = { create:O => [ { 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.instances.profiles[0].id} }, ], fetch:O => [O.instances.uploads[0].id,{filename:O.instances.uploads[0].filename}], update:O => [ { $set:{ status:{name:"Saved",time:new Date()}, } } ], query:O => [ {query:{"owner.ref":O.users.john}}, {query:{"title":"check it"}}, ], }; export type uploadFactoryTests = { create:FactoryTestFunc["uploads"]["create"]; fetch:FactoryTestFunc["uploads"]["fetch"]; updateSetAndPush:FactoryTestFunc["uploads"]["update"]; updatePull:FactoryTestFunc["uploads"]["update"]; fetchFinal:FactoryTestFunc["uploads"]["fetch"]; query:FactoryTestFunc["uploads"]["query"]; }; export const uploadFactoryTests:uploadFactoryTests = { create:async O => { const C = uploadFactoryTestData.create(O); for(let i = 0,l = C.length;i { const F = uploadFactoryTestData.fetch(O); for(let i = 0,l = F.length;i { const U = uploadFactoryTestData.update(O); for(let i = 0,l = U.length;i { const U = uploadFactoryTestData.update(O); for(let i = 0,l = U.length;i { const F = uploadFactoryTestData.fetch(O); const o = await O.factories.uploads.fetch(F[0]); J.is(o); J.not(o,null); const j = o.json(); J.is(j.status?.name,"Saved"); }, query:async O => { const Q = uploadFactoryTestData.query(O); for(let i = 0,l = Q.length;i J.desc("Uploads",() => { it("Create",async () => await uploadFactoryTests.create(O),1E9); it("Fetch",async () => await uploadFactoryTests.fetch(O),1E9); it("Update - Set & Push",async () => await uploadFactoryTests.updateSetAndPush(O),1E9); it("Update - Pull",async () => await uploadFactoryTests.updatePull(O),1E9); it("Fetch - Final Check",async () => await uploadFactoryTests.fetchFinal(O),1E9); it("Query",async () => await uploadFactoryTests.query(O),1E9); });