move to native esm
master
Kebler Network System Administrator 2021-04-24 19:23:51 -07:00
parent cf3c23f9e2
commit df01b54ba6
3 changed files with 23 additions and 16 deletions

View File

@ -62,4 +62,4 @@ rect.color = "red"
Credits Credits
------- -------
aggregation 2015-2019 by Dr. Ralf S. Engelschall (http://engelschall.com/) thx to aggregation 2015-2019 by Dr. Ralf S. Engelschall (http://engelschall.com/)

View File

@ -1,11 +1,12 @@
{ {
"name": "@uci-utils/class-merge", "name": "@uci-utils/class-merge",
"version": "1.0.3", "version": "1.1.0",
"description": "Function to merge classes when making an extended class", "description": "Function to merge classes when making an extended class",
"main": "src/merge.js", "main": "src/merge.js",
"type": "module",
"scripts": { "scripts": {
"test": "./node_modules/.bin/mocha -r esm --timeout 30000", "test": "./node_modules/.bin/mocha --timeout 30000",
"testd": "UCI_ENV=dev ./node_modules/.bin/nodemon --exec './node_modules/.bin/mocha -r esm --timeout 30000' || exit 0" "testd": "UCI_ENV=dev ./node_modules/.bin/nodemon --exec './node_modules/.bin/mocha --timeout 30000' || exit 0"
}, },
"author": "David Kebler", "author": "David Kebler",
"license": "MIT", "license": "MIT",
@ -26,8 +27,7 @@
"homepage": "https://github.com/uCOMmandIt/uci-utils/class-merge#readme", "homepage": "https://github.com/uCOMmandIt/uci-utils/class-merge#readme",
"devDependencies": { "devDependencies": {
"chai": "^4.2.0", "chai": "^4.2.0",
"chai-eventemitter": "^1.1.1", "chai-eventemitter2": "^0.2.1",
"esm": "^3.2.25",
"mocha": "^7.0.1", "mocha": "^7.0.1",
"nodemon": "^2.0.2" "nodemon": "^2.0.2"
} }

View File

@ -1,9 +1,9 @@
import merge from '../src/merge.js' import merge from '../src/merge.js'
import chai, { expect } from 'chai' import chai, { expect } from 'chai'
import eventemitter from 'chai-eventemitter' import eventemitter from 'chai-eventemitter2'
import { EventEmitter as Emitter } from 'events' import { EventEmitter as Emitter } from 'events'
chai.use(eventemitter) chai.use(eventemitter())
describe('Class Merge', function () { describe('Class Merge', function () {
@ -43,14 +43,21 @@ describe('Class Merge', function () {
}) })
it('Should handle more complex mixin', function () { it('Should handle more complex mixin, i.e. with eventEmitter', function () {
// rect.on('test',(data)=>expect(data).to.be.equal('some data'))
// rect.emit('test','some data') expect(rect).to.be.an.eventEmitter
expect(function(){ rect.emit('test', 'some data') }).to.emitFrom(rect, 'test', 'some data') expect(rect)
.to.emit('foo')
.to.emit('bar', {count: 2})
.to.emit('baz', {withArgs: ['X', 'Y', 'Z']})
.to.emit('error', {count: 0})
.on(() =>
{
rect.emit('foo')
rect.emit('bar')
rect.emit('bar')
rect.emit('baz', 'X', 'Y', 'Z')
})
}) })
}) })