Skip to content

Commit

Permalink
refactor(test): modernizes test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Mar 8, 2024
1 parent 09d701c commit 4794f73
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
19 changes: 6 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@
"query-string": "^7.1.1"
},
"devDependencies": {
"chai": "^4.3.6",
"c8": "9.1.0",
"dependency-cruiser": "16.2.3",
"eslint": "8.57.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.1.1",
"mocha": "10.3.0",
"node-localstorage": "3.0.5",
"npm-run-all": "4.1.5",
"nyc": "15.1.0",
"sass": "1.71.1",
"sw-precache": "5.2.1",
"upem": "9.0.3",
Expand All @@ -53,11 +51,6 @@
},
"upem": {
"policies": [
{
"package": "chai",
"policy": "wanted",
"because": "chai > 4 are ESM and we aren't yet"
},
{
"package": "codemirror",
"policy": "wanted",
Expand All @@ -73,10 +66,10 @@
"scripts": {
"build": "make clean build",
"check": "npm-run-all --parallel depcruise lint test:cover",
"depcruise": "depcruise --validate -- src/script",
"depcruise": "depcruise src/script",
"depcruise:graph": "npm-run-all --parallel depcruise:graph:*",
"depcruise:graph:png": "depcruise --validate --output-type dot src/script/mscgen-interpreter.js | dot -Gdpi=192 -Gsplines=ortho -T png | pngquant - > docs/dependencygraph.png",
"depcruise:graph:html": "depcruise --validate --output-type dot src/script/mscgen-interpreter.js | dot -Gsplines=ortho -T svg | depcruise-wrap-stream-in-html > docs/dependencygraph.html",
"depcruise:graph:png": "depcruise --output-type dot src/script/mscgen-interpreter.js | dot -Gdpi=192 -Gsplines=ortho -T png | pngquant - > docs/dependencygraph.png",
"depcruise:graph:html": "depcruise --output-type dot src/script/mscgen-interpreter.js | dot -Gsplines=ortho -T svg | depcruise-wrap-stream-in-html > docs/dependencygraph.html",
"lint": "eslint src",
"lint:fix": "eslint --fix src",
"scm:push": "run-p --aggregate-output scm:push:*",
Expand All @@ -90,8 +83,8 @@
"scm:push:bitbucket-mirror:commits": "git push bitbucket-mirror",
"scm:push:bitbucket-mirror:tags": "git push --tags bitbucket-mirror",
"scm:stage": "git add .",
"test": "mocha --reporter dot --recursive src/script/test",
"test:cover": "nyc --check-coverage npm test",
"test": "node --test-reporter ./tools/dot-with-summary.reporter.js --test src/script/test/**/*.spec.js",
"test:cover": "c8 npm test",
"update-dependencies": "npm-run-all upem:update upem:install lint:fix build check",
"upem-outdated": "npm outdated --json --long | upem --dry-run",
"upem:update": "npm outdated ---json --long | upem | pbcopy && pbpaste",
Expand Down
10 changes: 6 additions & 4 deletions src/script/test/interpreter/sampleListReader.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/* eslint max-len:0 */
const sampleListReader = require('../../interpreter/sampleListReader')
const fixture = require('./sampleListReaderFixture.json')
const expect = require('chai').expect
const assert = require('node:assert/strict')
const { describe, it } = require('node:test')
// kutjelikken is

describe('sampleListReader', function () {
const OPTIONS_NO_DEBUG_FIXTURE = '<optgroup label="first option group"><option value="samples/debug-not-specified.mscgen">debug not specified</option><option value="samples/debug-false-sample.mscgen">debug false</option></optgroup><optgroup label="second option group"><option value="getikt">mesjogge</option><option value="leip">knetter</option></optgroup>'
const OPTIONS_DEBUG_FIXTURE = '<optgroup label="first option group"><option value="samples/debug-not-specified.mscgen">debug not specified</option><option value="samples/debug-false-sample.mscgen">debug false</option><option value="samples/debug-true-sample.mscgen">debug true</option></optgroup><optgroup label="second option group"><option value="getikt">mesjogge</option><option value="leip">knetter</option></optgroup>'

it('should return no debug options when debug not specified', function () {
expect(sampleListReader.toOptionList(fixture)).to.equal(OPTIONS_NO_DEBUG_FIXTURE)
assert.deepEqual(sampleListReader.toOptionList(fixture), OPTIONS_NO_DEBUG_FIXTURE)
})
it('should return no debug options when debug false', function () {
expect(sampleListReader.toOptionList(fixture, false)).to.equal(OPTIONS_NO_DEBUG_FIXTURE)
assert.deepEqual(sampleListReader.toOptionList(fixture, false), OPTIONS_NO_DEBUG_FIXTURE)
})
it('should also return debug options when debug true', function () {
expect(sampleListReader.toOptionList(fixture, true)).to.equal(OPTIONS_DEBUG_FIXTURE)
assert.deepEqual(sampleListReader.toOptionList(fixture, true), OPTIONS_DEBUG_FIXTURE)
})
})
3 changes: 2 additions & 1 deletion src/script/test/utl/exporter.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint max-len:0 */
const assert = require('assert')
const assert = require('node:assert/strict')
const xport = require('../../utl/exporter')
const { describe, it } = require('node:test')

const gAST = {
meta: {
Expand Down
3 changes: 2 additions & 1 deletion src/script/test/utl/maps.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const assert = require('chai').assert
const assert = require('node:assert/strict')
const map = require('../../utl/maps')
const { describe, it } = require('node:test')

describe('ui/utl/maps', function () {
describe('#classifyExtension() - ', function () {
Expand Down
3 changes: 2 additions & 1 deletion src/script/test/utl/store.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* global localStorage, global */

const store = require('../../utl/store')
const assert = require('assert')
const assert = require('node:assert/strict')
const { describe, it, before, after, beforeEach } = require('node:test')

describe('ui/utl/store', function () {
let lLanguage = 'initial language'
Expand Down

0 comments on commit 4794f73

Please sign in to comment.