diff --git a/integration-test.js b/integration-test.js new file mode 100644 index 0000000..0a9a168 --- /dev/null +++ b/integration-test.js @@ -0,0 +1,16 @@ +const express = require('express'); +const chai = require('chai'); +const request = require('supertest'); +const app = express(); + +describe('POST Create User Wallet', () => { + it('should create wallet for the user', () => { + request(app) + .post('123456/wallet') + .send({}) + .expect(201) + .then((res) => { + expect(res.headers.location).to.be.eql('123456/wallet'); + }); + }); +}); \ No newline at end of file diff --git a/package.json b/package.json index a64e6a6..a6c203c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Integration Library for IdentityBlock Person Verification Platform", "main": "api.js", "scripts": { - "test": "jest" + "test": "mocha --recursive --exit" }, "repository": { "type": "git", @@ -18,12 +18,14 @@ "homepage": "https://github.com/IdentityBlock/IntegrationLibrary#readme", "dependencies": { "dotenv": "^16.0.3", + "express": "^4.18.2", "fs": "^0.0.1-security", "qrcode": "^1.5.1", "web3": "^1.8.1" }, "devDependencies": { "jest": "^29.3.1", - "jsdoc-to-markdown": "^7.1.1" + "jsdoc-to-markdown": "^7.1.1", + "mocha": "^10.1.0" } -} \ No newline at end of file +} diff --git a/test.js b/test.js new file mode 100644 index 0000000..432246f --- /dev/null +++ b/test.js @@ -0,0 +1,87 @@ +// Requiring module +const assert = require('assert'); +const { + deployContract, + getVerifiedToken, + getUserName, + getUserEmail, + getUserDOB, + getUserCountry, + getUserMobile, + getUserGender, + } = require("./contract.js"); + +describe("Unit testing of contract.js", () => { + before(() => { + console.log( "Starting" ); + }); + + after(() => { + console.log( "Testing done" ); + }); + + describe( "getUserName function", () => { + beforeEach(() => { + console.log( "Starting getUserName testing" ); + }); + + it("Test 1", async () => { + assert.equal(await getUserName("0x6102Fb1Caea3Ab5ED5a8Ac844BdB7F28bc8363D1", "0xe43FD05d7E2257e2265099cf5Fe87602a6DEfE91"), "Kasun Isuranga"); + }); + }); + + describe( "getUserEmail function", () => { + beforeEach(() => { + console.log( "Starting getUserEmail testing" ); + }); + + it("Test 1", async () => { + assert.equal(await getUserEmail("0x6102Fb1Caea3Ab5ED5a8Ac844BdB7F28bc8363D1", "0xe43FD05d7E2257e2265099cf5Fe87602a6DEfE91"), "kasunisuranga.19@cse.mrt.ac.lk"); + }); + }); + + describe( "getUserDOB function", () => { + beforeEach(() => { + console.log( "Starting getUserDOB testing" ); + }); + + it("Test 1", async () => { + assert.equal(await getUserDOB("0x6102Fb1Caea3Ab5ED5a8Ac844BdB7F28bc8363D1", "0xe43FD05d7E2257e2265099cf5Fe87602a6DEfE91"), "2000-01-12"); + }); + }); + + describe( "getUserCountry function", () => { + beforeEach(() => { + console.log( "Starting getUserCountry testing" ); + }); + + it("Test 1", async () => { + assert.equal(await getUserCountry("0x6102Fb1Caea3Ab5ED5a8Ac844BdB7F28bc8363D1", "0xe43FD05d7E2257e2265099cf5Fe87602a6DEfE91"), "Sri Lanka"); + }); + }); + + describe( "getUserMobile function", () => { + beforeEach(() => { + console.log( "Starting getUserMobile testing" ); + }); + + it("Test 1", async () => { + assert.equal(await getUserMobile("0x6102Fb1Caea3Ab5ED5a8Ac844BdB7F28bc8363D1", "0xe43FD05d7E2257e2265099cf5Fe87602a6DEfE91"), "+94711009825"); + }); + }); + + describe( "getUserGender function", () => { + beforeEach(() => { + console.log( "Starting getUserGender testing" ); + }); + + it("Test 1", async () => { + assert.equal(await getUserGender("0x6102Fb1Caea3Ab5ED5a8Ac844BdB7F28bc8363D1", "0xe43FD05d7E2257e2265099cf5Fe87602a6DEfE91"), "Male"); + }); + }); +}); + +getUserName("0x417fB7b824D97f4554aD61A97d254c24f7C84d20", "0x6102Fb1Caea3Ab5ED5a8Ac844BdB7F28bc8363D1").then((data) => { + console.log(data) + } +); \ No newline at end of file diff --git a/test_server.js b/test_server.js new file mode 100644 index 0000000..04af895 --- /dev/null +++ b/test_server.js @@ -0,0 +1,18 @@ +const express = require("express") +const app = express() + +app.use("/loadContract", (req, res, next) => { + res.send("This is the express server") +}) + +app.get("/getQR", (req, res, next) => { + res.send("This is the hello response"); +}) + +app.get("/getTokenVerified", (req, res, next) => { + res.send("This is the hello response"); +}) + +app.listen(3000, () => { + console.log("Server is Running") +}) \ No newline at end of file