Skip to content

Commit

Permalink
Added untranspiled tests for issue
Browse files Browse the repository at this point in the history
README suggests classes can be constructed using `new` but this does not appear to be the case. #46
#46
The issue only occurs in untranspiled code.
  • Loading branch information
Download committed Jul 16, 2018
1 parent 963e28f commit b35739b
Show file tree
Hide file tree
Showing 4 changed files with 547 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"module": "dist/mics.es.js",
"scripts": {
"test": "mocha \"dist/mics.spec.js\"",
"test-untranspiled": "mocha \"src/untranspiled.spec.js\"",
"dev": "webpack-dev-server --output-path test --output-filename index.spec.js \"mocha-loader!./index.spec.js\" --content-base test --port 8888",
"build": "npm run build-cjs && npm run build-umd && npm run build-min && npm run build-es && npm run build-test",
"build-cjs": "webpack --output-path dist --output-filename mics.cjs.js --output-library-target commonjs2 \"./index.js\" ",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { mix, is, like }
module.exports = { mix, is, like }

/**
* Accepts an optional superclass as the first argument,
Expand Down
53 changes: 53 additions & 0 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,59 @@ describe('mix([superclass] [, ...mixins] [, factory])', function() {
it('created mixins can be invoked without new to instantiate instances', function(){
const M = mix(superclass => class M extends superclass {})
const m = M()
expect(m).to.be.an('object')
})

it('mixins created from factories with a constructor can be invoked without new to instantiate instances', function(){
const M = mix(superclass => class M extends superclass {
constructor(){
super()
console.info('constructor called')
}
})
const m = M()
expect(m).to.be.an('object')
})

it('mixins created from factories with a constructor can be invoked with new to instantiate instances', function(){
const M = mix(superclass => class M extends superclass {
constructor(){
super()
console.info('constructor called')
}
})
const m = new M()
expect(m).to.be.an('object')
})

it('mixins created from ES6 classes can be invoked with new to instantiate instances', function(){
class B {}
const M = mix(B)
const m = new M()
expect(m).to.be.an('object')
})



it('mixins created from ES6 classes can be invoked without new to instantiate instances', function(){
class B {}
const M = mix(B)
const m = M()
expect(m).to.be.an('object')
})

it('mixins created from ES6 classes can be invoked with new to instantiate instances', function(){
class B {}
const M = mix(B)
const m = new M()
expect(m).to.be.an('object')
})



it('mixins created from classes without a constructor can be invoked without new to instantiate instances', function(){
const M = mix(superclass => class M extends superclass {})
const m = M()

expect(m).to.be.an('object')
})
Expand Down
Loading

0 comments on commit b35739b

Please sign in to comment.