Skip to content

Commit

Permalink
test: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Apr 22, 2024
1 parent 39343e0 commit d59dc60
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lib/rdfLoaders.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import LoaderRegistry from 'rdf-loaders-registry'
import EcmaScriptLoader from 'rdf-loader-code/ecmaScript.js'
import EcmaScriptModuleLoader from 'rdf-loader-code/ecmaScriptModule.js'
import EcmaScriptLiteralLoader from 'rdf-loader-code/ecmaScriptLiteral.js'

export const loaders = new LoaderRegistry()
EcmaScriptLoader.register(loaders)
EcmaScriptModuleLoader.register(loaders)
EcmaScriptLiteralLoader.register(loaders)
2 changes: 2 additions & 0 deletions test/lib/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { expect } from 'chai'
import { createApi } from '../../lib/index.js'
import $rdf from '../support/env.js'

const __dirname = path.dirname(new URL(import.meta.url).pathname)

describe('lib', () => {
const apiPath = path.resolve(__dirname, '../test-api')

Expand Down
2 changes: 2 additions & 0 deletions test/lib/middleware/preprocessResource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { query } from '../../../lib/namespace.js'
import { preprocessResource } from '../../../lib/middleware/preprocessResource.js'
import { loaders } from '../../../lib/rdfLoaders.js'

const __dirname = new URL('.', import.meta.url).pathname

describe('labyrinth/lib/middleware/preprocessResource', () => {
let enrichmentSpy: sinon.SinonSpy

Expand Down
7 changes: 4 additions & 3 deletions test/lib/query/collections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { sparql, SparqlTemplateResult } from '@tpluscode/rdf-string'
import { CONSTRUCT, SELECT } from '@tpluscode/sparql-builder'
import $rdf from '../../support/env.js'
import { getSparqlQuery } from '../../../lib/query/collection.js'
import '../../support/sparql.js'
import { ex } from '../../support/namespace.js'
import * as ns from '../../../lib/namespace.js'
import '../../support/sparql.js'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const basePath = path.resolve(__dirname, '../../')

type ExpectedQuerySetup = SparqlTemplateResult | {
Expand Down Expand Up @@ -202,8 +203,8 @@ describe('labyrinth/lib/query/collection', () => {
property: schema.title,
variable: 'title',
[ns.query.filter.value]: {
types: [ns.code.EcmaScript],
[ns.code.link.value]: $rdf.namedNode('file:test-api/filter#byTitle'),
types: [ns.code.EcmaScriptModule],
[ns.code.link.value]: $rdf.namedNode('file:test-api/filter.js#byTitle'),
},
}],
}),
Expand Down
11 changes: 10 additions & 1 deletion test/support/sparql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ import { SparqlTemplateResult } from '@tpluscode/rdf-string'

const sparqlParser = new Parser()

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Chai {
interface Assertion {
query(expected: string | SparqlTemplateResult): typeof Assertion
}
}
}

// eslint-disable-next-line no-undef
Assertion.addMethod('query', function (this: Chai.AssertionStatic, expected: string | SparqlTemplateResult) {
Assertion.addMethod('query', function (this, expected: string | SparqlTemplateResult) {
let expectedQuery: SparqlQuery
let actualQuery: SparqlQuery

Expand Down
5 changes: 0 additions & 5 deletions types/chai.d.ts

This file was deleted.

0 comments on commit d59dc60

Please sign in to comment.