Skip to content

Commit

Permalink
test: fix test env
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Apr 16, 2024
1 parent 5494ff4 commit 493d185
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 48 deletions.
7 changes: 1 addition & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions packages/lit-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@
},
"devDependencies": {
"@open-wc/testing": "^3.1.6",
"@rdfjs/environment": "^1",
"@rdfine/rdfs": "^0.8.4",
"@rdfjs/data-model": "^2",
"@rdfjs/dataset": "^2",
"@rdfjs/types": "^1.1.0",
"@tpluscode/rdfine": "^0.7.5",
"@types/clownface": "^2.0.7",
"@zazuko/env": "^2.1.1",
"crypto-js": "^4.2.0",
"typescript": "^4.7.2"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/lit-helpers/test/env.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Environment from '@rdfjs/environment/Environment.js'
import Environment from '@zazuko/env/Environment.js'
import parent from '@zazuko/env/web.js'
import { RdfsFactory } from '@rdfine/rdfs/Factory'
import { RdfineFactory } from '@tpluscode/rdfine'
import DataFactory from '@rdfjs/data-model/Factory.js'

export default new Environment([RdfineFactory, RdfsFactory, DataFactory])
export default new Environment([RdfineFactory, RdfsFactory], { parent })
31 changes: 10 additions & 21 deletions packages/lit-helpers/test/localizedLabel.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { html, fixture, expect, nextFrame } from '@open-wc/testing'
import clownface from 'clownface'
import $rdf from '@rdfjs/dataset'
import { rdfs, sh } from '@tpluscode/rdf-ns-builders'
import { setLanguages } from '../index.js'
import { localizedLabel } from '../localizedLabel.js'
Expand All @@ -9,7 +7,7 @@ import env from './env.js'
describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {
it("renders pointer's rdfs:label property in preferred language", async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
pointer
.addOut(rdfs.label, pointer.literal('Apfel', 'de'))
.addOut(rdfs.label, pointer.literal('Apple', 'en'))
Expand All @@ -25,7 +23,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('skips languages not found', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
pointer
.addOut(rdfs.label, pointer.literal('Apfel', 'de'))
.addOut(rdfs.label, pointer.literal('Apple', 'en'))
Expand All @@ -41,7 +39,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('falls back to any language when no matching tag is found', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
pointer.addOut(rdfs.label, pointer.literal('Apfel', 'de'))
setLanguages('fr', 'pl')

Expand All @@ -54,7 +52,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('works with rdfine object', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
const resource = env.rdfine.rdfs.Resource(pointer, {
label: 'Apple',
})
Expand All @@ -68,7 +66,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('updates existing usages when language is changed', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() })
const pointer = env.clownface()
const apple = pointer
.blankNode()
.addOut(rdfs.label, pointer.literal('Apple', 'en'))
Expand All @@ -94,7 +92,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('updates existing fallback usages when language is changed', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() })
const pointer = env.clownface()
const fruit = pointer.blankNode()

// when
Expand All @@ -111,7 +109,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('renders fallback when no label is found', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() })
const pointer = env.clownface()
const res = pointer.blankNode()

// when
Expand All @@ -125,10 +123,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('supports changing the label property', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).addOut(
sh.name,
'Property'
)
const pointer = env.clownface().addOut(sh.name, 'Property')
const res = pointer.blankNode()

// when
Expand All @@ -147,10 +142,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('binds to property', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).addOut(
sh.name,
'Property'
)
const pointer = env.clownface().addOut(sh.name, 'Property')
const res = pointer.blankNode()

// when
Expand All @@ -169,10 +161,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('binds to attribute', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).addOut(
sh.name,
'Property'
)
const pointer = env.clownface().addOut(sh.name, 'Property')
const res = pointer.blankNode()

// when
Expand Down
23 changes: 9 additions & 14 deletions packages/lit-helpers/test/localizedLiteral.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { html, fixture, expect, nextFrame } from '@open-wc/testing'
import clownface from 'clownface'
import $rdf from '@rdfjs/dataset'
import { rdfs, sh, skos } from '@tpluscode/rdf-ns-builders'
import { setLanguages } from '../index.js'
import { localizedLabel } from '../localizedLabel.js'
Expand All @@ -9,7 +7,7 @@ import env from './env.js'
describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {
it("renders pointer's rdfs:label property in preferred language", async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
pointer
.addOut(rdfs.label, pointer.literal('Apfel', 'de'))
.addOut(rdfs.label, pointer.literal('Apple', 'en'))
Expand All @@ -25,7 +23,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('skips languages not found', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
pointer
.addOut(rdfs.label, pointer.literal('Apfel', 'de'))
.addOut(rdfs.label, pointer.literal('Apple', 'en'))
Expand All @@ -41,7 +39,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('falls back to any language when no matching tag is found', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
pointer.addOut(rdfs.label, pointer.literal('Apfel', 'de'))
setLanguages('fr', 'pl')

Expand All @@ -54,7 +52,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('works with rdfine object', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
const resource = env.rdfine.rdfs.Resource(pointer, {
label: 'Apple',
})
Expand All @@ -68,7 +66,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('updates existing usages when language is changed', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() })
const pointer = env.clownface()
const apple = pointer
.blankNode()
.addOut(rdfs.label, pointer.literal('Apple', 'en'))
Expand All @@ -94,7 +92,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('updates existing fallback usages when language is changed', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() })
const pointer = env.clownface()
const fruit = pointer.blankNode()

// when
Expand All @@ -111,7 +109,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('renders fallback when no label is found', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() })
const pointer = env.clownface()
const res = pointer.blankNode()

// when
Expand All @@ -125,10 +123,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('supports changing the label property', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).addOut(
sh.name,
'Property'
)
const pointer = env.clownface().addOut(sh.name, 'Property')
const res = pointer.blankNode()

// when
Expand All @@ -147,7 +142,7 @@ describe('@rdfjs-elements/lit-helpers/localizedLabel.js', () => {

it('supports multiple alternative label properties', async () => {
// given
const pointer = clownface({ dataset: $rdf.dataset() }).blankNode()
const pointer = env.clownface().blankNode()
pointer.addOut(skos.altLabel, pointer.literal('Malus domestica'))

// when
Expand Down

0 comments on commit 493d185

Please sign in to comment.