@joystick.js/test-canary 0.0.0-canary.85 → 0.0.0-canary.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import r from"./test.js";import o from"./helpers/api/index.js";import t from"./helpers/render/index.js";import e from"./helpers/databases/index.js";import m from"./helpers/email/index.js";import a from"./helpers/queues/index.js";import f from"./helpers/load/index.js";import i from"./helpers/routes/index.js";import p from"./helpers/uploaders/index.js";import s from"./helpers/websockets/index.js";var q={accounts:{login:r.login,signup:r.signup},after:r.after,afterEach:r.afterEach,api:o,before:r.before,beforeEach:r.beforeEach,render:t,databases:e,email:m,load:f,queues:a,routes:i,that:r.that,uploaders:p,websockets:s};export{q as default};
1
+ import r from"./test.js";import e from"./helpers/api/index.js";import o from"./helpers/render/index.js";import t from"./helpers/databases/index.js";import m from"./helpers/email/index.js";import a from"./helpers/queues/index.js";import f from"./helpers/load/index.js";import p from"./helpers/routes/index.js";import i from"./helpers/uploaders/index.js";import s from"./helpers/websockets/index.js";var k={accounts:{signup:r.signupUser,delete:r.deleteUser},after:r.after,afterEach:r.afterEach,api:e,before:r.before,beforeEach:r.beforeEach,render:o,databases:t,email:m,load:f,queues:a,routes:p,that:r.that,uploaders:i,websockets:s};export{k as default};
package/dist/test.js CHANGED
@@ -1 +1 @@
1
- import t from"ava";import r from"node-fetch";let s=[];class c{constructor(){t.serial.after.always(()=>{console.log("CLEANUP USERS",s)})}async signup(e=[]){for(let o=0;o<e?.length;o+=1){const a=e[o],n=await r(`http://localhost:${process.env.PORT}/api/_accounts/signup`,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).then(l=>l.json());s.push(n)}}delete(e=""){r(`http://localhost:${process.env.PORT}/api/_test/accounts`,{method:"DELETE",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e})})}before(e=null){return t.serial.before(e)}beforeEach(e=null){return t.beforeEach(e)}after(e=null){return t.after.always(e)}afterEach(e=null){return t.afterEach.always(e)}that(e="",o=null){return t.serial(e,o)}}var h=new c;export{h as default};
1
+ import r from"ava";import a from"node-fetch";let s=[];class c{constructor(){r.serial.after.always(async()=>{for(let e=0;e<s?.length;e+=1){const t=s[e];await this.deleteUser(t?._id||t?.user_id)}})}async signupUser(e=[]){for(let t=0;t<e?.length;t+=1){const o=e[t],n=await a(`http://localhost:${process.env.PORT}/api/_accounts/signup`,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).then(l=>l.json());s.push(n)}}deleteUser(e=""){return a(`http://localhost:${process.env.PORT}/api/_test/accounts`,{method:"DELETE",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e})})}before(e=null){return r.serial.before(e)}beforeEach(e=null){return r.beforeEach(e)}after(e=null){return r.after.always(e)}afterEach(e=null){return r.afterEach.always(e)}that(e="",t=null){return r.serial(e,t)}}var p=new c;export{p as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/test-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.85",
4
+ "version": "0.0.0-canary.87",
5
5
  "description": "Isomorphic testing framework for the Joystick JavaScript framework.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
package/src/index.js CHANGED
@@ -11,8 +11,9 @@ import websockets from './helpers/websockets/index.js';
11
11
 
12
12
  export default {
13
13
  accounts: {
14
- login: test.login,
15
- signup: test.signup,
14
+ // login: test.login,
15
+ signup: test.signupUser,
16
+ delete: test.deleteUser,
16
17
  },
17
18
  after: test.after,
18
19
  afterEach: test.afterEach,
package/src/test.js CHANGED
@@ -5,14 +5,18 @@ let users = [];
5
5
 
6
6
  class Test {
7
7
  constructor() {
8
- test.serial.after.always(() => {
8
+ test.serial.after.always(async () => {
9
9
  // NOTE: Nuke users who were created as part of the test run to avoid
10
10
  // data collisions in other tests/suites.
11
- console.log('CLEANUP USERS', users);
11
+
12
+ for (let i = 0; i < users?.length; i += 1) {
13
+ const user = users[i];
14
+ await this.deleteUser(user?._id || user?.user_id);
15
+ }
12
16
  });
13
17
  }
14
18
 
15
- async signup(usersToSignup = []) {
19
+ async signupUser(usersToSignup = []) {
16
20
  for (let i = 0; i < usersToSignup?.length; i += 1) {
17
21
  const userToSignup = usersToSignup[i];
18
22
  const user = await fetch(`http://localhost:${process.env.PORT}/api/_accounts/signup`, {
@@ -28,8 +32,8 @@ class Test {
28
32
  }
29
33
  }
30
34
 
31
- delete(userId = '') {
32
- fetch(`http://localhost:${process.env.PORT}/api/_test/accounts`, {
35
+ deleteUser(userId = '') {
36
+ return fetch(`http://localhost:${process.env.PORT}/api/_test/accounts`, {
33
37
  method: 'DELETE',
34
38
  mode: "cors",
35
39
  headers: {