Skip to content

Commit 820fbb4

Browse files
committed
test(defineOperation): add tests for defineOperation
1 parent 24a2c0f commit 820fbb4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/defineOperation_tests.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
const kerberos = require('bindings')('kerberos');
3+
const defineOperation = require('../lib/util').defineOperation;
4+
const expect = require('chai').expect;
5+
6+
const testMethod = defineOperation(kerberos._testMethod, [
7+
{ name: 'string', type: 'string' },
8+
{ name: 'shouldError', type: 'boolean', default: false },
9+
{ name: 'callback', type: 'function', required: false }
10+
]);
11+
12+
describe('defineOperation', () => {
13+
it('should validate parameters', function() {
14+
expect(() => testMethod(42)).to.throw(/Invalid type for parameter/);
15+
});
16+
17+
it('should return a promise if no callback is provided', function() {
18+
const promise = testMethod('llamas', false);
19+
expect(promise).to.be.instanceOf(Promise);
20+
});
21+
});

0 commit comments

Comments
 (0)