42 lines
1005 B
JavaScript
42 lines
1005 B
JavaScript
import merge from '../src/merge.js'
|
|
import { expect } from 'chai'
|
|
|
|
|
|
describe('Class Merge', function () {
|
|
|
|
class Colored {
|
|
initializer () { this._color = 'white' }
|
|
get color () { return this._color }
|
|
set color (v) { this._color = v }
|
|
}
|
|
|
|
class ZCoord {
|
|
initializer () { this._z = 0 }
|
|
get z () { return this._z }
|
|
set z (v) { this._z = v }
|
|
}
|
|
|
|
class Shape {
|
|
constructor (x, y) { this._x = x; this._y = y }
|
|
get x () { return this._x }
|
|
set x (v) { this._x = v }
|
|
get y () { return this._y }
|
|
set y (v) { this._y = v }
|
|
}
|
|
|
|
var Rectangle = class Rectangle extends merge(Shape, Colored, ZCoord) {}
|
|
|
|
var rect = new Rectangle(7, 42)
|
|
rect.z = 1000
|
|
rect.color = 'red'
|
|
|
|
|
|
it('Should merge three classes', function () {
|
|
expect(rect.x).to.be.equal(7)
|
|
expect(rect.y).to.be.equal(42)
|
|
expect(rect.z).to.be.equal(1000)
|
|
expect(rect.color).to.be.equal('red')
|
|
})
|
|
|
|
})
|