import {J} from "../../utils"; import { FactoryTestData, FactoryTestFunc, FactoryNetwork } from "../types"; export type profileFactoryTestData = { create:FactoryTestData["profiles"]["create"]; fetch:FactoryTestData["profiles"]["fetch"]; update:FactoryTestData["profiles"]["update"]; query:FactoryTestData["profiles"]["query"]; }; export const profileFactoryTestData:profileFactoryTestData = { create:O => [ { name:O.users.john, role:"ADMIN", },{ name:O.users.jim, role:"USER", },{ name:O.users.jenn, role:"USER", }, ], fetch:O => [O.instances.profiles[0].id,{name:O.instances.profiles[1].name}], update:O => [ { $set:{ name:O.users.jack, status:{name:"Enabled",time:new Date()}, "settings.data":{...O.instances.profiles[0].settings?.data,timeout:3600}, "settings.app.withBal":true, "settings.app.optionsOnly":true, "socials.fb":"boopscoop", "stats.views":17, "rating":4.8, "bio":"whatever whatevr whatevs", "motto":"No", }, $push:{ "activity":[ {name:"create-profile",time:new Date(),}, {name:"sent-message",time:new Date(),}, ], "followers":O.instances.profiles[1].id, "following":[O.instances.profiles[1].id], "endorsements":O.instances.profiles[1].id, }, $pull:{"following":{$in:[O.instances.profiles[1].id]},}, } ], query:O => [ {query:{"name":O.users.jack}}, {query:{"role":"USER"}}, {query:{following:{$in:[O.instances.profiles[1].id]}}}, ], }; export type profileFactoryTests = { create:FactoryTestFunc["profiles"]["create"]; fetch:FactoryTestFunc["profiles"]["fetch"]; updateSetAndPush:FactoryTestFunc["profiles"]["update"]; updatePull:FactoryTestFunc["profiles"]["update"]; fetchFinal:FactoryTestFunc["profiles"]["fetch"]; query:FactoryTestFunc["profiles"]["query"]; }; export const profileFactoryTests:profileFactoryTests = { create:async O => { const C = profileFactoryTestData.create(O); for(let i = 0,l = C.length;i { const F = profileFactoryTestData.fetch(O); for(let i = 0,l = F.length;i { const U = profileFactoryTestData.update(O); for(let i = 0,l = U.length;i { const U = profileFactoryTestData.update(O); for(let i = 0,l = U.length;i { const F = profileFactoryTestData.fetch(O); const o = await O.factories.profiles.fetch(F[0]); J.is(o); J.not(o,null); const j = o.json(); J.is(j.status?.name,"Enabled"); J.is(j.name,O.users.jack); }, query:async O => { const Q = profileFactoryTestData.query(O); for(let i = 0,l = Q.length;i J.desc("User Profiles",() => { it("Create",async () => await profileFactoryTests.create(O),1E9); it("Fetch",async () => await profileFactoryTests.fetch(O),1E9); it("Update - Set & Push",async () => await profileFactoryTests.updateSetAndPush(O),1E9); it("Update - Pull",async () => await profileFactoryTests.updatePull(O),1E9); it("Fetch - Final Check",async () => await profileFactoryTests.fetchFinal(O),1E9); it("Query",async () => await profileFactoryTests.query(O),1E9); });