From b7e4fc30c51ef29c0236c97a283a5db6cb0c119d Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 16 Jun 2018 14:33:58 +0300 Subject: [PATCH] Unit test for Ethereum Signature --- tests/signature-service.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/signature-service.js b/tests/signature-service.js index 3971b7f..4c936fa 100644 --- a/tests/signature-service.js +++ b/tests/signature-service.js @@ -23,6 +23,8 @@ describe('Signature service', () => { signatureService = { validateKryptedSignature : sinon.stub().returns('squirtle'), sign: sinon.stub().returns('squirtle'), + validateEthereumSignature : sinon.stub().returns(''), + signatureMessage : sinon.stub().returns('I, Krypted, signing this diploma as the issuer') }; responseJson = sinon.stub(); @@ -60,11 +62,11 @@ describe('Signature service', () => { //Assert signatureService.sign.calledWith('Pikachu') ; assert.equal(result,'squirtle'); - const digitalPorfileStub = { + const modelStub = { kryptedSignature: '' }; - signatureService.sign.calledWith(digitalPorfileStub); - digitalPorfileStub.kryptedSignature = 'squirtle'; + signatureService.sign.calledWith(modelStub); + modelStub.kryptedSignature = 'squirtle'; responseJson.calledWith('squirtle') done(); }); @@ -78,4 +80,18 @@ describe('Signature service', () => { responseJson.calledWith({ error: 'undefined krypted signature' }); done(); }); - }); \ No newline at end of file + describe('Ethereum signature controll', () => { + it('should singature message issureAuthority equal object issuerAuthority', () => { + //Act + const result = signatureService.validateEthereumSignature('squirtle','0x58','Pikachu'); + + //Assert + const modelStub = { + profile : { + issuerAuthority : 'Krypted' + } + }; + assert.equal(`I, ${modelStub.profile.issuerAuthority}, signing this diploma as the issuer`, signatureService.signatureMessage()); + }); + }); + }); \ No newline at end of file