@joystick.js/test-canary 0.0.0-canary.78 → 0.0.0-canary.79

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/test.js CHANGED
@@ -1 +1 @@
1
- import r from"ava";let t=[];r.serial.after.always(()=>{console.log("CLEANUP USERS",t)});class a{constructor(){}signup(e=[]){t.push(...e)}login(e={}){}accounts(){return{signup:this.signup,login:this.login}}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="",l=null){return r.serial(e,l)}}var u=new a;export{u as default};
1
+ import t from"ava";import"url";import a from"node-fetch";let o=[];t.serial.after.always(()=>{console.log("CLEANUP USERS",o)});class l{constructor(){}async signup(e=[]){for(let r=0;r<e?.length;r+=1){const s=e[r],n=await a(`http://localhost:${process.env.PORT}/api/_accounts/signup`,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});o.push(n)}}login(e={}){}accounts(){return{signup:this.signup,login:this.login}}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)}}var h=new l;export{h 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.78",
4
+ "version": "0.0.0-canary.79",
5
5
  "description": "Isomorphic testing framework for the Joystick JavaScript framework.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
package/src/test.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import test from 'ava';
2
+ import { URL } from "url";
3
+ import fetch from 'node-fetch';
2
4
 
3
5
  let users = [];
4
6
 
5
- // NOTE: Internal cleaup to avoid confusing tests.
6
7
  test.serial.after.always(() => {
8
+ // NOTE: Nuke users who were created as part of the test run to avoid
9
+ // data collisions in other tests/suites.
7
10
  console.log('CLEANUP USERS', users);
8
11
  });
9
12
 
@@ -12,9 +15,20 @@ class Test {
12
15
 
13
16
  }
14
17
 
15
- signup(usersToSignup = []) {
16
- users.push(...usersToSignup);
17
- // TODO: As users are created in DB, push them into an array here in the test.
18
+ async signup(usersToSignup = []) {
19
+ for (let i = 0; i < usersToSignup?.length; i += 1) {
20
+ const userToSignup = usersToSignup[i];
21
+ const user = await fetch(`http://localhost:${process.env.PORT}/api/_accounts/signup`, {
22
+ method: 'POST',
23
+ mode: "cors",
24
+ headers: {
25
+ "Content-Type": "application/json",
26
+ },
27
+ body: JSON.stringify(userToSignup)
28
+ });
29
+
30
+ users.push(user);
31
+ }
18
32
  }
19
33
 
20
34
  login(user = {}) {