Skip to content

Commit

Permalink
revert: unwanted state modification
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Nov 29, 2024
1 parent 5fca7a8 commit aaa8390
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ignore:
- demos
- test-setup.js
- packages/core-tests/test-setup.js
- karma.conf.js
- types
- packages/*/test
Expand Down
12 changes: 1 addition & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "eslint . --ext .ts --quiet --ignore-path .gitignore --ignore-path .eslintignore",
"build": "wsrun -m build",
"test": "run-p test:*",
"test:core": "c8 --all -o coverage/core --reporter=lcov mocha --recursive 'packages/core-tests/**/*.test.ts'",
"test:core": "c8 --all -o coverage/core --reporter=lcov npm run -w @hydrofoil/shaperone-core-tests test",
"test:web": "web-test-runner",
"release": "changeset publish",
"docs": "docsify serve ./dist",
Expand All @@ -28,7 +28,6 @@
"@web/dev-server-rollup": "^0.6.4",
"@web/test-runner": "^0.19",
"c8": "^7.1.2",
"chai-snapshot-matcher": "^1.0.6",
"docsify-cli": "^4.4.1",
"es-dev-commonjs-transformer": "^0.2.0",
"eslint-import-resolver-typescript": "^3.6.1",
Expand All @@ -52,15 +51,6 @@
"resolutions": {
"@polymer/polymer": "3.4.1"
},
"mocha": {
"watch-files": [
"./**/*.ts"
],
"require": [
"test-setup.js"
],
"loader": "ts-node/esm/transpile-only"
},
"lint-staged": {
"*.{js,ts}": [
"eslint --fix --quiet"
Expand Down
10 changes: 10 additions & 0 deletions packages/core-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"private": true,
"version": "0.1.1",
"type": "module",
"scripts": {
"test": "mocha \"**/*.ts\""
},
"devDependencies": {
"@hydrofoil/shaperone-core": "*",
"@rdfine/shacl": "^0.10.5",
Expand All @@ -17,10 +20,17 @@
"@types/mocha": "^9.1.1",
"@types/sinon-chai": "^3.2.4",
"autoesm": "^1.0.5",
"chai-snapshot-matcher": "^1.0.6",
"chai-subset": "^1.6.0",
"chai-quantifiers": "^1.0.10",
"deepmerge": "^4.2.2",
"promise-the-world": "^1.0.1",
"rdf-dataset-ext": "^1.1.0"
},
"mocha": {
"require": [
"./test-setup.js"
],
"loader": "ts-node/esm/transpile-only"
}
}
17 changes: 17 additions & 0 deletions packages/core-tests/test-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'chai-snapshot-matcher'
import chaiQuantifiers from 'chai-quantifiers'
import chai from 'chai'
import sinonChai from 'sinon-chai'
import chaiSubset from 'chai-subset'
import { setEnv } from '@hydrofoil/shaperone-core/env.js'
import rdf from '@zazuko/env'

chai.use(sinonChai)
chai.use(chaiQuantifiers)
chai.use(chaiSubset)

export const mochaHooks = {
beforeAll() {
setEnv(rdf)
},
}
3 changes: 2 additions & 1 deletion packages/core/models/shapes/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ export const setGraph = formStateReducer((state: ShapeState, { shapesGraph }: Se
const newAnyPointer = shapesGraph !== state.shapesGraph && (!shapesGraph.term || !state.shapesGraph?.term)

const shapes = findShapes(shapesGraph)
draft.shapes = shapes
if (newDataset || newAnyPointer) {
// pointer to a different dataset
draft.shapesGraph = shapesGraph
draft.shapes = shapes
draft.preferredRootShape = getPreferredShape(shapesGraph, shapes)
return
}

if (shapesGraph.term && !shapesGraph.term.equals(state.shapesGraph?.term)) {
// same dataset, changed pointer
draft.shapes = shapes
draft.preferredRootShape = getPreferredShape(shapesGraph, shapes)

Check warning on line 58 in packages/core/models/shapes/reducers.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/models/shapes/reducers.ts#L57-L58

Added lines #L57 - L58 were not covered by tests
}
}), emptyState)
11 changes: 0 additions & 11 deletions test-setup.js

This file was deleted.

0 comments on commit aaa8390

Please sign in to comment.