Skip to content

Commit 0546763

Browse files
authored
Merge pull request #39 from iden3/fix/add-loader
Fix cache loader. Pass loader in test
2 parents 41b3c56 + 8ce10c7 commit 0546763

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tests/cache.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { Options } from '../src/lib/types/types';
44
import { W3C_CREDENTIAL_2018, W3C_VC_SCHEMA } from './data';
55
import { DocumentLoader } from '../src/loaders/jsonld-loader';
66

7-
const cache = new Map<string, RemoteDocument>();
8-
cache.set(W3C_CREDENTIAL_2018, {
9-
document: W3C_VC_SCHEMA,
10-
documentUrl: W3C_CREDENTIAL_2018
11-
});
127
export const cacheLoader = (opts?: Options): DocumentLoader => {
8+
const cache = new Map<string, RemoteDocument>();
9+
cache.set(W3C_CREDENTIAL_2018, {
10+
document: W3C_VC_SCHEMA,
11+
documentUrl: W3C_CREDENTIAL_2018
12+
});
1313
return async (url): Promise<RemoteDocument> => {
1414
let remoteDoc = cache.get(url);
1515
if (remoteDoc) {

tests/merklization.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1178,9 +1178,9 @@ describe('merklize document with ipfs context', () => {
11781178
});
11791179

11801180
it('IPFS is not configured', async () => {
1181-
await expect(Merklizer.merklizeJSONLD(ipfsDocument)).rejects.toThrow(
1182-
'Dereferencing a URL did not result in a valid JSON-LD object'
1183-
);
1181+
await expect(
1182+
Merklizer.merklizeJSONLD(ipfsDocument, { documentLoader: cacheLoader() })
1183+
).rejects.toThrow('Dereferencing a URL did not result in a valid JSON-LD object');
11841184
});
11851185

11861186
it('TestExistenceProofIPFS', async () => {

0 commit comments

Comments
 (0)