Skip to content

Commit a715daf

Browse files
committed
fixed some tests
1 parent 8384c7b commit a715daf

File tree

5 files changed

+11
-234
lines changed

5 files changed

+11
-234
lines changed

test/Auth/methods.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const
55
User = require('../../src/security/User.js'),
66
Security = require('../../src/security/Security.js');
77

8-
describe.only('Kuzzle Auth controller', function () {
8+
describe('Kuzzle Auth controller', function () {
99
let
1010
auth,
1111
kuzzle;

test/kuzzle/login.test.js

Lines changed: 0 additions & 179 deletions
This file was deleted.

test/kuzzle/methods.test.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -263,46 +263,6 @@ describe('Kuzzle methods', function () {
263263
});
264264
});
265265

266-
describe('#getMyRights', function() {
267-
it('should trigger callback with an error', function (done) {
268-
var
269-
cberror = {message: 'i am an error'},
270-
spy = sandbox.stub(kuzzle, 'query').yields(cberror),
271-
args;
272-
273-
kuzzle.getMyRights(function (err) {
274-
should(err).be.exactly(cberror);
275-
args = spy.firstCall.args;
276-
277-
should(spy).be.calledOnce();
278-
279-
should(args[0].controller).be.exactly('auth');
280-
should(args[0].action).be.exactly('getMyRights');
281-
should(args[2]).be.exactly(null);
282-
done();
283-
});
284-
});
285-
286-
it('should call query with right arguments', function (done) {
287-
var
288-
doc = {_id: '42'},
289-
spy = sandbox.stub(kuzzle, 'query').yields(null, {result: {hits: [doc]}}),
290-
args;
291-
292-
kuzzle.getMyRights(function (err, res) {
293-
should(res).be.an.Array().and.containEql(doc);
294-
args = spy.firstCall.args;
295-
296-
should(spy).be.calledOnce();
297-
298-
should(args[0].controller).be.exactly('auth');
299-
should(args[0].action).be.exactly('getMyRights');
300-
should(args[2]).be.exactly(null);
301-
done();
302-
});
303-
});
304-
});
305-
306266
describe('#getServerInfo', function () {
307267
var expectedQuery = {
308268
controller: 'server',

test/kuzzle/query.test.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ describe('Kuzzle query management', function () {
2525
});
2626

2727
kuzzle = new Kuzzle('foo');
28-
});
28+
kuzzle.network.query.resolves({result:{}});
29+
});
2930

3031
it('should generate a valid request object with no "options" argument and no callback', function () {
3132
kuzzle.query(queryArgs, queryBody);
@@ -56,9 +57,7 @@ describe('Kuzzle query management', function () {
5657
});
5758

5859
it('should manage arguments properly if no options are provided', function () {
59-
var cb = sinon.stub();
60-
61-
kuzzle.query(queryArgs, queryBody, cb);
60+
kuzzle.query(queryArgs, queryBody);
6261
should(kuzzle.network.query).be.calledOnce();
6362
should(kuzzle.network.query).be.calledWith({
6463
action: 'action',
@@ -68,13 +67,11 @@ describe('Kuzzle query management', function () {
6867
index: 'index',
6968
volatile: { sdkInstanceId: kuzzle.network.id, sdkVersion: kuzzle.sdkVersion },
7069
requestId: sinon.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)
71-
}, null, sinon.match(function(f) {return f === cb;}));
70+
});
7271
});
7372

7473
it('should manage arguments properly if empty query and no options are provided', function () {
75-
var cb = sinon.stub();
76-
77-
kuzzle.query(queryArgs, cb);
74+
kuzzle.query(queryArgs);
7875
should(kuzzle.network.query).be.calledOnce();
7976
should(kuzzle.network.query).be.calledWith({
8077
action: 'action',
@@ -83,7 +80,7 @@ describe('Kuzzle query management', function () {
8380
index: 'index',
8481
volatile: { sdkInstanceId: kuzzle.network.id, sdkVersion: kuzzle.sdkVersion },
8582
requestId: sinon.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)
86-
}, null, sinon.match(function(f) {return f === cb;}));
83+
});
8784
});
8885

8986
it('should not define optional members if none was provided', function () {
@@ -92,10 +89,10 @@ describe('Kuzzle query management', function () {
9289
should(kuzzle.network.query).be.calledWithMatch({index: undefined});
9390
});
9491

95-
it('should invoke the callback with an error if no query is provided', function () {
96-
should(function () { kuzzle.query(queryArgs, ['foo', 'bar']); }).throw(Error);
97-
should(function () { kuzzle.query(queryArgs); }).throw(Error);
98-
should(function () { kuzzle.query(queryArgs, 'foobar'); }).throw(Error);
92+
it('should reject if no query is provided', function () {
93+
should(kuzzle.query(queryArgs, ['foo', 'bar'])).be.rejected();
94+
should(kuzzle.query(queryArgs)).be.rejected();
95+
should(kuzzle.query(queryArgs, 'foobar')).be.rejected();
9996
});
10097

10198
it('should handle options "volatile" properly', function () {

test/mocks/kuzzle.mock.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function KuzzleMock () {
1616
this.security = new Security(this);
1717
this.setJwt = sinon.stub();
1818
this.unsetJwt = sinon.stub();
19-
this.emit = sinon.stub();
2019

2120
this.callbackRequired = function (errorMessagePrefix, callback) {
2221
if (!callback || typeof callback !== 'function') {

0 commit comments

Comments
 (0)