Skip to content

Commit

Permalink
feat: working repository and record
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
berendsliedrecht committed Mar 29, 2022
1 parent 9496ac6 commit 001bbec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
7 changes: 3 additions & 4 deletions packages/core/src/modules/vc/W3cCredentialService.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import type { JwsLinkedDataSignature } from '../../crypto/JwsLinkedDataSignature'
import type { DidInfo } from '../../wallet'
import type { VerifyCredentialResult, W3cCredential, W3cVerifyCredentialResult } from './models'
import type { VerifyPresentationResult } from './models/presentation/VerifyPresentationResult'
import type { W3cPresentation } from './models/presentation/W3Presentation'
import type { RemoteDocument, Url } from 'jsonld/jsonld-spec'

// @ts-ignore
import { expand } from '@digitalcredentials/jsonld'
import jsonld, { expand } from '@digitalcredentials/jsonld'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import documentLoaderNode from '@digitalcredentials/jsonld/lib/documentLoaders/node'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import documentLoaderXhr from '@digitalcredentials/jsonld/lib/documentLoaders/xhr'
import vc from '@digitalcredentials/vc'
import exp from 'constants'
import { inject, Lifecycle, scoped } from 'tsyringe'

import { AgentConfig } from '../../agent/AgentConfig'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jest.mock('../../ledger/services/IndyLedgerService')

const IndyLedgerServiceMock = IndyLedgerService as jest.Mock<IndyLedgerService>
const DidRepositoryMock = DidRepository as unknown as jest.Mock<DidRepository>

jest.mock('../models/credential/W3cCredentialRepository')
const W3cCredentialRepositoryMock = W3cCredentialRepository as jest.Mock<W3cCredentialRepository>

describe('W3cCredentialService', () => {
Expand Down Expand Up @@ -76,7 +78,21 @@ describe('W3cCredentialService', () => {
W3cVerifiableCredential
)

await expect(w3cCredentialService.storeCredential(credential)).resolves.toMatchObject({ id: expect.any(String) })
const w3cCredentialRecord = await w3cCredentialService.storeCredential(credential)

expect(w3cCredentialRecord).toMatchObject({
type: 'W3cCredentialRecord',
id: expect.any(String),
createdAt: expect.any(Date),
credential: expect.any(W3cVerifiableCredential),
})

expect(w3cCredentialRecord.getTags()).toMatchObject({
expandedTypes: [
'https://www.w3.org/2018/credentials#VerifiableCredential',
'https://example.org/examples#UniversityDegreeCredential',
],
})
})
})

Expand Down

0 comments on commit 001bbec

Please sign in to comment.