Add unit test for operation parsing
This commit is contained in:
parent
2cae521fb1
commit
5cd8985343
1 changed files with 22 additions and 0 deletions
22
test/unit/operation.js
Normal file
22
test/unit/operation.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const o = require('../../src/operation')
|
||||||
|
|
||||||
|
describe('Operation', function() {
|
||||||
|
|
||||||
|
it('op_prefix', function() {
|
||||||
|
o.op_prefix('arst').should.deep.equal({name: 'arst', operation: 'add'})
|
||||||
|
o.op_prefix('+arst').should.deep.equal({name: 'arst', operation: 'add'})
|
||||||
|
o.op_prefix('-arst').should.deep.equal({name: 'arst', operation: 'subtract'})
|
||||||
|
o.op_prefix('~arst').should.deep.equal({name: 'arst', operation: 'intersect'})
|
||||||
|
o.op_prefix('^arst').should.deep.equal({name: 'arst', operation: 'stack'})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('operation', function() {
|
||||||
|
// without choices, it's the same as op_prefix
|
||||||
|
o.operation('arst').should.deep.equal({name: 'arst', operation: 'add'})
|
||||||
|
// with choices, it propagates type where it found the name
|
||||||
|
o.operation('arst', {bad: [], good: ['arst']}).should.deep.equal({name: 'arst', operation: 'add', type: 'good'})
|
||||||
|
// it also respects order when overridden
|
||||||
|
o.operation('arst', {first: ['arst'], second: ['arst']}, ['second', 'first']).should.deep.equal({name: 'arst', operation: 'add', type: 'second'})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue