@joystick.js/test-canary 0.0.0-canary.86 → 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/test.js +1 -1
- package/package.json +1 -1
- package/src/test.js +7 -3
package/dist/test.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
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
package/src/test.js
CHANGED
|
@@ -5,10 +5,14 @@ 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
|
-
|
|
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
|
|
|
@@ -29,7 +33,7 @@ class Test {
|
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
deleteUser(userId = '') {
|
|
32
|
-
fetch(`http://localhost:${process.env.PORT}/api/_test/accounts`, {
|
|
36
|
+
return fetch(`http://localhost:${process.env.PORT}/api/_test/accounts`, {
|
|
33
37
|
method: 'DELETE',
|
|
34
38
|
mode: "cors",
|
|
35
39
|
headers: {
|