diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 9b59a54..62731c7 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -6,6 +6,29 @@ on:
- main
jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Use Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: "21"
+
+ - name: go to backend folder
+ run: cd backend
+
+ - name: Install dependencies
+ run: npm install
+
+ - name: Run pretests
+ run: npm run pretest
+
+ - name: Run tests
+ run: npm run test
+
# format:
# runs-on: ubuntu-latest
# steps:
@@ -17,6 +40,7 @@ jobs:
# run: terraform fmt
Deploy:
+ needs: test
# needs: format
runs-on: ubuntu-latest
steps:
diff --git a/backend/package-lock.json b/backend/package-lock.json
index 0bb5193..c60ca9a 100644
--- a/backend/package-lock.json
+++ b/backend/package-lock.json
@@ -19,6 +19,7 @@
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.1.1",
"nodemon": "^3.0.3",
+ "sinon": "^17.0.1",
"socket.io": "^4.6.2",
"toastr": "^2.1.4"
},
@@ -28,6 +29,7 @@
"@types/jsonwebtoken": "^9.0.5",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.7",
+ "@types/sinon": "^17.0.3",
"@types/toastr": "^2.1.43",
"esm": "^3.2.25",
"mocha": "^10.3.0",
@@ -99,6 +101,45 @@
"sparse-bitfield": "^3.0.3"
}
},
+ "node_modules/@sinonjs/commons": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz",
+ "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==",
+ "dependencies": {
+ "type-detect": "4.0.8"
+ }
+ },
+ "node_modules/@sinonjs/fake-timers": {
+ "version": "11.2.2",
+ "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-11.2.2.tgz",
+ "integrity": "sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==",
+ "dependencies": {
+ "@sinonjs/commons": "^3.0.0"
+ }
+ },
+ "node_modules/@sinonjs/samsam": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-8.0.0.tgz",
+ "integrity": "sha512-Bp8KUVlLp8ibJZrnvq2foVhP0IVX2CIprMJPK0vqGqgrDa0OHVKeZyBykqskkrdxV6yKBPmGasO8LVjAKR3Gew==",
+ "dependencies": {
+ "@sinonjs/commons": "^2.0.0",
+ "lodash.get": "^4.4.2",
+ "type-detect": "^4.0.8"
+ }
+ },
+ "node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-2.0.0.tgz",
+ "integrity": "sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==",
+ "dependencies": {
+ "type-detect": "4.0.8"
+ }
+ },
+ "node_modules/@sinonjs/text-encoding": {
+ "version": "0.7.2",
+ "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz",
+ "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ=="
+ },
"node_modules/@socket.io/component-emitter": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
@@ -275,6 +316,21 @@
"@types/node": "*"
}
},
+ "node_modules/@types/sinon": {
+ "version": "17.0.3",
+ "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-17.0.3.tgz",
+ "integrity": "sha512-j3uovdn8ewky9kRBG19bOwaZbexJu/XjtkHyjvUgt4xfPFz18dcORIMqnYh66Fx3Powhcr85NT5+er3+oViapw==",
+ "dev": true,
+ "dependencies": {
+ "@types/sinonjs__fake-timers": "*"
+ }
+ },
+ "node_modules/@types/sinonjs__fake-timers": {
+ "version": "8.1.5",
+ "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.5.tgz",
+ "integrity": "sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==",
+ "dev": true
+ },
"node_modules/@types/sizzle": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.8.tgz",
@@ -1308,7 +1364,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true,
"engines": {
"node": ">=8"
}
@@ -1567,6 +1622,11 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
+ "node_modules/just-extend": {
+ "version": "6.2.0",
+ "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-6.2.0.tgz",
+ "integrity": "sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw=="
+ },
"node_modules/jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
@@ -1609,6 +1669,11 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/lodash.get": {
+ "version": "4.4.2",
+ "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
+ "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ=="
+ },
"node_modules/lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
@@ -2014,6 +2079,23 @@
"node": ">= 0.6"
}
},
+ "node_modules/nise": {
+ "version": "5.1.9",
+ "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.9.tgz",
+ "integrity": "sha512-qOnoujW4SV6e40dYxJOb3uvuoPHtmLzIk4TFo+j0jPJoC+5Z9xja5qH5JZobEPsa8+YYphMrOSwnrshEhG2qww==",
+ "dependencies": {
+ "@sinonjs/commons": "^3.0.0",
+ "@sinonjs/fake-timers": "^11.2.2",
+ "@sinonjs/text-encoding": "^0.7.2",
+ "just-extend": "^6.2.0",
+ "path-to-regexp": "^6.2.1"
+ }
+ },
+ "node_modules/nise/node_modules/path-to-regexp": {
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz",
+ "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw=="
+ },
"node_modules/node-addon-api": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz",
@@ -2600,6 +2682,42 @@
"node": ">=10"
}
},
+ "node_modules/sinon": {
+ "version": "17.0.1",
+ "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz",
+ "integrity": "sha512-wmwE19Lie0MLT+ZYNpDymasPHUKTaZHUH/pKEubRXIzySv9Atnlw+BUMGCzWgV7b7wO+Hw6f1TEOr0IUnmU8/g==",
+ "dependencies": {
+ "@sinonjs/commons": "^3.0.0",
+ "@sinonjs/fake-timers": "^11.2.2",
+ "@sinonjs/samsam": "^8.0.0",
+ "diff": "^5.1.0",
+ "nise": "^5.1.5",
+ "supports-color": "^7.2.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/sinon"
+ }
+ },
+ "node_modules/sinon/node_modules/diff": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz",
+ "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==",
+ "engines": {
+ "node": ">=0.3.1"
+ }
+ },
+ "node_modules/sinon/node_modules/supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/socket.io": {
"version": "4.7.4",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.4.tgz",
@@ -2885,6 +3003,14 @@
"node": ">=0.3.1"
}
},
+ "node_modules/type-detect": {
+ "version": "4.0.8",
+ "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
+ "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
@@ -3165,6 +3291,47 @@
"sparse-bitfield": "^3.0.3"
}
},
+ "@sinonjs/commons": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz",
+ "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==",
+ "requires": {
+ "type-detect": "4.0.8"
+ }
+ },
+ "@sinonjs/fake-timers": {
+ "version": "11.2.2",
+ "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-11.2.2.tgz",
+ "integrity": "sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==",
+ "requires": {
+ "@sinonjs/commons": "^3.0.0"
+ }
+ },
+ "@sinonjs/samsam": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-8.0.0.tgz",
+ "integrity": "sha512-Bp8KUVlLp8ibJZrnvq2foVhP0IVX2CIprMJPK0vqGqgrDa0OHVKeZyBykqskkrdxV6yKBPmGasO8LVjAKR3Gew==",
+ "requires": {
+ "@sinonjs/commons": "^2.0.0",
+ "lodash.get": "^4.4.2",
+ "type-detect": "^4.0.8"
+ },
+ "dependencies": {
+ "@sinonjs/commons": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-2.0.0.tgz",
+ "integrity": "sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==",
+ "requires": {
+ "type-detect": "4.0.8"
+ }
+ }
+ }
+ },
+ "@sinonjs/text-encoding": {
+ "version": "0.7.2",
+ "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz",
+ "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ=="
+ },
"@socket.io/component-emitter": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
@@ -3341,6 +3508,21 @@
"@types/node": "*"
}
},
+ "@types/sinon": {
+ "version": "17.0.3",
+ "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-17.0.3.tgz",
+ "integrity": "sha512-j3uovdn8ewky9kRBG19bOwaZbexJu/XjtkHyjvUgt4xfPFz18dcORIMqnYh66Fx3Powhcr85NT5+er3+oViapw==",
+ "dev": true,
+ "requires": {
+ "@types/sinonjs__fake-timers": "*"
+ }
+ },
+ "@types/sinonjs__fake-timers": {
+ "version": "8.1.5",
+ "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.5.tgz",
+ "integrity": "sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==",
+ "dev": true
+ },
"@types/sizzle": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.8.tgz",
@@ -4108,8 +4290,7 @@
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"has-property-descriptors": {
"version": "1.0.2",
@@ -4297,6 +4478,11 @@
}
}
},
+ "just-extend": {
+ "version": "6.2.0",
+ "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-6.2.0.tgz",
+ "integrity": "sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw=="
+ },
"jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
@@ -4330,6 +4516,11 @@
"p-locate": "^5.0.0"
}
},
+ "lodash.get": {
+ "version": "4.4.2",
+ "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
+ "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ=="
+ },
"lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
@@ -4619,6 +4810,25 @@
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg=="
},
+ "nise": {
+ "version": "5.1.9",
+ "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.9.tgz",
+ "integrity": "sha512-qOnoujW4SV6e40dYxJOb3uvuoPHtmLzIk4TFo+j0jPJoC+5Z9xja5qH5JZobEPsa8+YYphMrOSwnrshEhG2qww==",
+ "requires": {
+ "@sinonjs/commons": "^3.0.0",
+ "@sinonjs/fake-timers": "^11.2.2",
+ "@sinonjs/text-encoding": "^0.7.2",
+ "just-extend": "^6.2.0",
+ "path-to-regexp": "^6.2.1"
+ },
+ "dependencies": {
+ "path-to-regexp": {
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz",
+ "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw=="
+ }
+ }
+ },
"node-addon-api": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz",
@@ -5047,6 +5257,34 @@
"semver": "^7.5.3"
}
},
+ "sinon": {
+ "version": "17.0.1",
+ "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz",
+ "integrity": "sha512-wmwE19Lie0MLT+ZYNpDymasPHUKTaZHUH/pKEubRXIzySv9Atnlw+BUMGCzWgV7b7wO+Hw6f1TEOr0IUnmU8/g==",
+ "requires": {
+ "@sinonjs/commons": "^3.0.0",
+ "@sinonjs/fake-timers": "^11.2.2",
+ "@sinonjs/samsam": "^8.0.0",
+ "diff": "^5.1.0",
+ "nise": "^5.1.5",
+ "supports-color": "^7.2.0"
+ },
+ "dependencies": {
+ "diff": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz",
+ "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A=="
+ },
+ "supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "requires": {
+ "has-flag": "^4.0.0"
+ }
+ }
+ }
+ },
"socket.io": {
"version": "4.7.4",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.4.tgz",
@@ -5251,6 +5489,11 @@
}
}
},
+ "type-detect": {
+ "version": "4.0.8",
+ "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
+ "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g=="
+ },
"type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
diff --git a/backend/package.json b/backend/package.json
index 815d9ec..b2975c8 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -24,6 +24,7 @@
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.1.1",
"nodemon": "^3.0.3",
+ "sinon": "^17.0.1",
"socket.io": "^4.6.2",
"toastr": "^2.1.4"
},
@@ -33,6 +34,7 @@
"@types/jsonwebtoken": "^9.0.5",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.7",
+ "@types/sinon": "^17.0.3",
"@types/toastr": "^2.1.43",
"esm": "^3.2.25",
"mocha": "^10.3.0",
diff --git a/backend/src/models/single_user.ts b/backend/src/models/single_user.ts
index addf564..853ca0b 100644
--- a/backend/src/models/single_user.ts
+++ b/backend/src/models/single_user.ts
@@ -1,6 +1,6 @@
import { Schema, model, Document, Model } from "mongoose";
-interface ISingleUser extends Document {
+export interface ISingleUser extends Document {
username: string;
socketId: string;
}
diff --git a/backend/src/tests/rooms.test.ts b/backend/src/tests/rooms.test.ts
index 22b636e..f893e74 100644
--- a/backend/src/tests/rooms.test.ts
+++ b/backend/src/tests/rooms.test.ts
@@ -1,5 +1,5 @@
import { expect } from "chai";
-import { Room } from "../models/room";
+import { Room } from "../models/room.js";
describe("Room Model", () => {
describe("Instantiation", () => {
@@ -7,7 +7,7 @@ describe("Room Model", () => {
const data = {
_id: "1",
name: "Global Chatroom",
- userId: "user123"
+ userId: "user123",
};
const room = new Room(data);
diff --git a/backend/src/tests/single_user.test.ts b/backend/src/tests/single_user.test.ts
deleted file mode 100644
index f1ac815..0000000
--- a/backend/src/tests/single_user.test.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { expect } from "chai";
-import { SingleUser } from "../models/single_user";
-
-describe("SingleUser Model", () => {
- describe("Instantiation", () => {
- it("should create a new SingleUser object", () => {
- const data = {
- username: "testuser",
- socketId: "socket123"
- };
-
- const singleUser = new SingleUser(data);
-
- expect(singleUser.username).to.equal(data.username);
- expect(singleUser.socketId).to.equal(data.socketId);
- });
- });
-
- describe("Static Methods", () => {
- it("should return all single user objects", async () => {
- const users = await SingleUser.findAll();
- expect(users).to.be.an('array');
- });
-
- it("should find a single user by socketId", async () => {
- const user = await SingleUser.findOneByUsername('socket123');
- expect(user).to.be.an('object');
- expect(user?.socketId).to.equal('socket123');
- });
- });
-});
diff --git a/backend/src/tests/socket.test.ts b/backend/src/tests/socket.test.ts
index 3f2cdd7..641a9c5 100644
--- a/backend/src/tests/socket.test.ts
+++ b/backend/src/tests/socket.test.ts
@@ -1,5 +1,5 @@
import { expect } from "chai";
-import { Message } from "../models/messages";
+import { Message } from "../models/messages.js";
describe("Socket Routes", () => {
describe("Message", () => {
diff --git a/backend/src/tests/user.test.ts b/backend/src/tests/user.test.ts
index 2950972..bbb92ba 100644
--- a/backend/src/tests/user.test.ts
+++ b/backend/src/tests/user.test.ts
@@ -1,30 +1,43 @@
-import { expect } from 'chai';
-import { User } from '../models/user';
+import { expect } from "chai";
+import sinon from "sinon";
+import { User } from "../models/user.js";
-describe('User Model', () => {
- describe('Instantiation', () => {
- it('should create a new User object', () => {
+describe("User Model", () => {
+ describe("Instantiation", () => {
+ it("should create a new User object", () => {
const data = {
- username: 'testuser',
- email: 'testuser@example.com',
- password: 'password123',
- userId: 'userid123',
+ username: "testuser",
+ email: "testuser@example.com",
+ password: "password123",
+ userId: "userid123",
};
const user = new User(data);
- expect(user).to.have.property('username', data.username);
- expect(user).to.have.property('email', data.email);
- expect(user).to.have.property('password', data.password);
- expect(user).to.have.property('userId', data.userId);
- expect(user).to.have.property('createdAt').that.is.an.instanceof(Date);
+ expect(user).to.have.property("username", data.username);
+ expect(user).to.have.property("email", data.email);
+ expect(user).to.have.property("password", data.password);
+ expect(user).to.have.property("userId", data.userId);
+ expect(user).to.have.property("createdAt").that.is.an.instanceof(Date);
});
});
- describe('Static Methods', () => {
- it('should return all user objects', async () => {
+ describe("Static Methods", () => {
+ it("should return all user objects", async () => {
+ // Create a stub for the User.findAll method
+ const stub = sinon.stub(User, "findAll");
+ // Make the stub return a Promise that resolves to an array
+ stub.resolves([]);
+
const users = await User.findAll();
- expect(users).to.be.an('array');
+
+ // Make sure the stub was called
+ sinon.assert.calledOnce(stub);
+
+ expect(users).to.be.an("array");
+
+ // Restore the original method
+ stub.restore();
});
});
});
diff --git a/frontend/src/app/signin/page.tsx b/frontend/src/app/signin/page.tsx
index aad161f..44e3953 100644
--- a/frontend/src/app/signin/page.tsx
+++ b/frontend/src/app/signin/page.tsx
@@ -17,7 +17,12 @@ export default function SignIn() {
const canvasRef = useRef(null);
useEffect(() => {
- if (canvasRef.current) {
+ // Check if the user is on a mobile device
+ const isMobile = /iPhone|iPad|iPod|Android/i.test(
+ window.navigator.userAgent
+ );
+
+ if (canvasRef.current && !isMobile) {
const app = new Application(canvasRef.current);
app.load("https://prod.spline.design/hnkOtrqss6sQ-wLy/scene.splinecode");
}
@@ -94,7 +99,7 @@ export default function SignIn() {
{isLoading ?