@joystick.js/test-canary 0.0.0-canary.95 → 0.0.0-canary.97

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 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};
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 i from"./helpers/routes/index.js";import p from"./helpers/uploaders/index.js";import s from"./helpers/websockets/index.js";var k={accounts:{login:r.loginUser,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:i,that:r.that,uploaders:p,websockets:s};export{k as default};
package/dist/test.js CHANGED
@@ -1 +1 @@
1
- import t from"ava";import a from"node-fetch";let n=[];class u{constructor(){}async signupUser(e=[]){for(let r=0;r<e?.length;r+=1){const l=e[r],c=await a(`http://localhost:${process.env.PORT}/api/_test/accounts/signup`,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}).then(i=>i.json());n.push(c)}}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 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="",r=null){return t.serial(e,r)}}const o=new u;t.serial.after.always(async()=>{for(let s=0;s<n?.length;s+=1){const e=n[s];await o.deleteUser(e?._id||e?.user_id)}});var f=o;export{f as default};
1
+ import s from"ava";import o from"node-fetch";let a=[];class u{constructor(){this.currentUser=null}async signupUser(e=[]){for(let t=0;t<e?.length;t+=1){const r=e[t],c=await o(`http://localhost:${process.env.PORT}/api/_test/accounts/signup`,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then(i=>i.json());a.push(c)}}loginUser(e=""){const t=a?.find(r=>r?.emailAddress===e||r?.email_address===e);return this.currentUser=t||null,t}deleteUser(e=""){return o(`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 s.serial.before(e)}beforeEach(e=null){return s.beforeEach(e)}after(e=null){return s.after.always(e)}afterEach(e=null){return s.afterEach.always(e)}that(e="",t=null){return s.serial(e,r=>{t(r,this.currentUser)})}}const l=new u;s.serial.after.always(async()=>{for(let n=0;n<a?.length;n+=1){const e=a[n];await l.deleteUser(e?._id||e?.user_id)}});var p=l;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.95",
4
+ "version": "0.0.0-canary.97",
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,7 +11,7 @@ import websockets from './helpers/websockets/index.js';
11
11
 
12
12
  export default {
13
13
  accounts: {
14
- // login: test.login,
14
+ login: test.loginUser,
15
15
  signup: test.signupUser,
16
16
  delete: test.deleteUser,
17
17
  },
package/src/test.js CHANGED
@@ -5,6 +5,7 @@ let users = [];
5
5
 
6
6
  class Test {
7
7
  constructor() {
8
+ this.currentUser = null;
8
9
  }
9
10
 
10
11
  async signupUser(usersToSignup = []) {
@@ -23,6 +24,12 @@ class Test {
23
24
  }
24
25
  }
25
26
 
27
+ loginUser(emailAddress = '') {
28
+ const user = users?.find((user) => user?.emailAddress === emailAddress || user?.email_address === emailAddress);
29
+ this.currentUser = user || null;
30
+ return user;
31
+ }
32
+
26
33
  deleteUser(userId = '') {
27
34
  return fetch(`http://localhost:${process.env.PORT}/api/_test/accounts`, {
28
35
  method: 'DELETE',
@@ -59,7 +66,9 @@ class Test {
59
66
  that(description = '', callback = null) {
60
67
  // NOTE: Always run serial so we don't have collisions on component instances
61
68
  // for DOM tests.
62
- return test.serial(description, callback);
69
+ return test.serial(description, (assert) => {
70
+ callback(assert, this.currentUser);
71
+ });
63
72
  }
64
73
  }
65
74