Skip to content

Commit

Permalink
WOOP
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Feb 16, 2024
1 parent 27251a3 commit ec488a3
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 76 deletions.
File renamed without changes.
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
],
"exports": {
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./core": {
"import": "./dist/core.esm.js",
"require": "./dist/core.js"
"import": "./dist/core.js",
"require": "./dist/core.cjs"
},
"./dist/assets/*.css": "./dist/assets/*.css",
"./package.json": "./package.json"
Expand All @@ -23,10 +23,10 @@
"build": "run-p bundle",
"bundle": "rollup -c",
"bundle:watch": "rollup -c -w",
"lint": "eslint .",
"lint": "eslint . --ext js,cjs,mjs",
"dev": "npm test -- --auto-watch --no-single-run",
"test": "karma start karma.config.js",
"test:build": "mocha --reporter=spec --recursive test/distro/*.spec.js",
"test": "karma start karma.config.cjs",
"test:build": "mocha --reporter=spec --recursive test/distro/*.spec.c?js",
"start": "cross-env SINGLE_START=cloud-templates npm run dev",
"start:templates": "cross-env SINGLE_START=templates npm run dev",
"prepare": "run-s bundle"
Expand All @@ -45,8 +45,9 @@
"properties-panel",
"element-templates"
],
"main": "dist/index.js",
"module": "dist/index.esm.js",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"author": {
"name": "Nico Rehwaldt",
"url": "https://github.com/nikku"
Expand Down
3 changes: 3 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
],
"globals": {
"sinon": true
},
"parserOptions": {
"ecmaVersion": 2020
}
}
43 changes: 24 additions & 19 deletions test/TestHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,8 @@ import Modeler from 'bpmn-js/lib/Modeler';
import BPMNModdle from 'bpmn-moddle';
import zeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe';

let PROPERTIES_PANEL_CONTAINER;

global.chai.use(function(chai, utils) {

utils.addMethod(chai.Assertion.prototype, 'jsonEqual', function(comparison) {
import propertiesPanelCSS from '@bpmn-io/properties-panel/dist/assets/properties-panel.css';

var actual = JSON.stringify(this._obj);
var expected = JSON.stringify(comparison);

this.assert(
actual == expected,
'expected #{this} to deep equal #{act}',
'expected #{this} not to deep equal #{act}',
comparison, // expected
this._obj, // actual
true // show diff
);
});
});

export * from 'bpmn-js/test/helper';

Expand All @@ -50,6 +33,8 @@ export {
createEvent
} from 'bpmn-js/test/util/MockEvents';

let PROPERTIES_PANEL_CONTAINER;

export function bootstrapPropertiesPanel(diagram, options, locals) {
return async function() {
const container = TestContainer.get(this);
Expand Down Expand Up @@ -283,4 +268,24 @@ export function createProcess(bpmn = '', bpmndi = '') {
</bpmn:process>
${ bpmndi }
`);
}
}

// additional chai helpers //////////////

global.chai.use(function(chai, utils) {

utils.addMethod(chai.Assertion.prototype, 'jsonEqual', function(comparison) {

var actual = JSON.stringify(this._obj);
var expected = JSON.stringify(comparison);

this.assert(
actual == expected,
'expected #{this} to deep equal #{act}',
'expected #{this} not to deep equal #{act}',
comparison, // expected
this._obj, // actual
true // show diff
);
});
});
10 changes: 8 additions & 2 deletions test/coverageBundle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
const allTests = require.context('./spec', true, /.spec\.js$/);
const allTests = import.meta.webpackContext('./spec', {
recursive: true,
regExp: /.spec\.js$/
});

allTests.keys().forEach(allTests);

const allSources = require.context('../src', true, /.*\.js$/);
const allSources = import.meta.webpackContext('../src', {
recursive: true,
regExp: /.*\.js$/
});

allSources.keys().forEach(allSources);
37 changes: 37 additions & 0 deletions test/distro/distro.spec.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const {
expect
} = require('chai');


describe('exports', function() {

it('should expose CJS bundle', function() {

expect(() => require.resolve('bpmn-js-element-templates')).not.to.throw;
expect(() => require.resolve('bpmn-js-elemenet-templates/core')).not.to.throw;

});

});


describe('assets', function() {

const EXPORTS = [
'bpmn-js-element-templates',
'bpmn-js-element-templates/core',
'bpmn-js-element-templates/dist/assets/element-templates.css',
'bpmn-js-element-templates/package.json'
];

EXPORTS.forEach(function(asset) {

it(`should expose <${asset}>`, function() {

expect(() => require.resolve(asset)).not.to.throw();

});

});

});
45 changes: 0 additions & 45 deletions test/distro/distro.spec.js

This file was deleted.

5 changes: 4 additions & 1 deletion test/testBundle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const allTests = require.context('./spec', true, /.spec\.js$/);
const allTests = import.meta.webpackContext('./spec', {
recursive: true,
regExp: /.spec\.js$/
});

allTests.keys().forEach(allTests);

0 comments on commit ec488a3

Please sign in to comment.