diff --git a/services/account-without-juggler/test/unit/account-controller.ts b/services/account-without-juggler/test/unit/account-controller.ts index 17df44d..e3ffbdf 100644 --- a/services/account-without-juggler/test/unit/account-controller.ts +++ b/services/account-without-juggler/test/unit/account-controller.ts @@ -1,68 +1,68 @@ -import { AccountController } from "../../controllers/AccountController"; -import { expect } from "@loopback/testlab"; -import { accountRepository } from "../../repositories/account"; +import { AccountController } from '../../controllers/AccountController'; +import { expect } from '@loopback/testlab'; +import { accountRepository } from '../../repositories/account'; let accCtrl: any; const testAcc = { - id: "test1", - customerNumber: "1234", + id: 'test1', + customerNumber: '1234', balance: 1000, - branch: "Toronto", - type: "Chequing", + branch: 'Toronto', + type: 'Chequing', avgBalance: 500, minimumBalance: 0 }; const brokenAcc = { - customerNumber: "123456", + customerNumber: '123456', balance: 1000, - branch: "Broke City", - type: "Chequing" + branch: 'Broke City', + type: 'Chequing' }; -describe("AccountController Unit Test Suite", () => { +describe('AccountController Unit Test Suite', () => { before(createAccountController); - it("creates an account instance", async () => { + it('creates an account instance', async () => { const result = await accCtrl.createAccount(testAcc); expect(result).to.deepEqual(testAcc); - const getResult = await accCtrl.getAccount('{"where":{"id":"test1"}}'); + const getResult = await accCtrl.getAccount('{'where':{'id':'test1'}}'); expect(getResult).to.not.be.empty(); expect(getResult).have.lengthOf(1); expect(getResult[0]).to.deepEqual(testAcc); }); - it("should not create an invalid instance", async () => { + it('should not create an invalid instance', async () => { try { await accCtrl.createAccount(brokenAcc); } catch (err) { expect(err).to.not.be.empty(); } }); - it("should not accept invalid args", async () => { + it('should not accept invalid args', async () => { try { - await accCtrl.getAccount(""); + await accCtrl.getAccount(''); } catch (err) { expect(err).to.not.be.empty(); } }); - it("updates an account instance", async () => { - const result = await accCtrl.updateAccount('{"id":"test1"}', { + it('updates an account instance', async () => { + const result = await accCtrl.updateAccount('{'id':'test1'}', { balance: 2000 }); expect(result.count).to.be.equal(1); - const getResult = await accCtrl.getAccount('{"where":{"id":"test1"}}'); + const getResult = await accCtrl.getAccount('{'where':{'id':'test1'}}'); expect(getResult).to.not.be.empty(); expect(getResult).have.lengthOf(1); expect(getResult[0].id).to.be.equal(testAcc.id); expect(getResult[0].toObject().balance).to.be.equal(2000); }); - it("deletes an account instance", async () => { - const result = await accCtrl.deleteAccount('{"id":"test1"}'); + it('deletes an account instance', async () => { + const result = await accCtrl.deleteAccount('{'id':'test1'}'); expect(result.count).to.be.equal(1); - const getResult = await accCtrl.getAccount('{"where":{"id":"test1"}}'); + const getResult = await accCtrl.getAccount('{'where':{'id':'test1'}}'); expect(getResult).to.be.empty(); }); });