diff --git a/lib/rdf/PrefetchedDocumentLoader.ts b/lib/rdf/PrefetchedDocumentLoader.ts index 65fb04b..169f064 100644 --- a/lib/rdf/PrefetchedDocumentLoader.ts +++ b/lib/rdf/PrefetchedDocumentLoader.ts @@ -17,6 +17,24 @@ export class PrefetchedDocumentLoader extends FetchDocumentLoader { public static readonly contextPattern: RegExp = /https:\/\/linkedsoftwaredependencies.org\/bundles\/npm\/componentsjs\/\^([0-9]+).0.0\/components\/context.jsonld/u; + /** + * @deprecated Use {@link PrefetchedDocumentLoader.cjsMajorVersion} instead. + */ + // eslint-disable-next-line ts/naming-convention + public static readonly CJS_MAJOR_VERSION: number = PrefetchedDocumentLoader.cjsMajorVersion; + + /** + * @deprecated Use {@link PrefetchedDocumentLoader.contextUrl} instead. + */ + // eslint-disable-next-line ts/naming-convention + public static readonly CONTEXT_URL: string = PrefetchedDocumentLoader.contextUrl; + + /** + * @deprecated Use {@link PrefetchedDocumentLoader.contextPattern} instead. + */ + // eslint-disable-next-line ts/naming-convention + public static readonly CONTEXT_PATTERN: RegExp = PrefetchedDocumentLoader.contextPattern; + private static readonly defaultContext: any = contextJson; private static readonly defaultContexts: Record = { diff --git a/test/unit/rdf/PrefetchedDocumentLoader-test.ts b/test/unit/rdf/PrefetchedDocumentLoader-test.ts index 5ae816f..690421e 100644 --- a/test/unit/rdf/PrefetchedDocumentLoader-test.ts +++ b/test/unit/rdf/PrefetchedDocumentLoader-test.ts @@ -20,6 +20,14 @@ describe('PrefetchedDocumentLoader', () => { }); }); + describe('deprecated static fields', () => { + it('equal their renamed fields', () => { + expect(PrefetchedDocumentLoader.CJS_MAJOR_VERSION).toBe(PrefetchedDocumentLoader.cjsMajorVersion); + expect(PrefetchedDocumentLoader.CONTEXT_URL).toBe(PrefetchedDocumentLoader.contextUrl); + expect(PrefetchedDocumentLoader.CONTEXT_PATTERN).toBe(PrefetchedDocumentLoader.contextPattern); + }); + }); + describe('load', () => { it('for a prefetched context', async() => { await expect(loader.load('http://example.org/context')).resolves diff --git a/test/unit/rdf/RdfParser-test.ts b/test/unit/rdf/RdfParser-test.ts index 4cba72f..15630d9 100644 --- a/test/unit/rdf/RdfParser-test.ts +++ b/test/unit/rdf/RdfParser-test.ts @@ -423,6 +423,17 @@ describe('RdfParser', () => { }); it('for a Turtle stream with a slow import followed by an import to unknown file', async() => { + const parse = RdfParser.prototype.parse; + let resolveSlowImport: () => void; + const slowImportEnded = new Promise(resolve => resolveSlowImport = resolve); + const parseSpy = jest.spyOn(RdfParser.prototype, 'parse') + .mockImplementation(function(this: RdfParser, textStream, parseOptions) { + const stream = parse.call(this, textStream, parseOptions); + if (parseOptions.path === 'http://example.org/myfileslow.ttl') { + stream.on('end', () => resolveSlowImport()); + } + return stream; + }); const options: RdfParserOptions = { path: 'path/to/file.ttl', }; @@ -431,6 +442,10 @@ describe('RdfParser', () => { `; await expect(arrayifyStream(parser.parse(streamifyString(doc), options))).rejects .toThrow(new Error(`Error while parsing file "path/to/file.ttl": URL not found: http://example.org/myfileunknown.ttl`)); + + // The slow import is still being parsed, so it must end before this test does + await slowImportEnded; + parseSpy.mockRestore(); }); it('for a Turtle stream with imports and a blank node prefix should derive prefixes for imports', async() => {