Commit 0a307d7f authored by Tristan Cavelier's avatar Tristan Cavelier

key typechecks synchronous tests error fix

parent 84107abc
/*jslint indent: 2, maxlen: 90, nomen: true */ /*jslint indent: 2, maxlen: 90, nomen: true */
/*global define, exports, require, module, jIO, window, test, /*global define, exports, require, module, jIO, test, stop,
raises, ok, equal, deepEqual, sinon */ raises, ok, equal, deepEqual, sinon, test_util */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
(function (dependencies, module) { (function (dependencies, module) {
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
if (typeof exports === 'object') { if (typeof exports === 'object') {
return module(require('jio')); return module(require('jio'));
} }
module(jIO); module(jIO, test_util);
}(['jio', 'qunit'], function (jIO) { }(['jio', 'test_util', 'qunit'], function (jIO, util) {
"use strict"; "use strict";
module('Key and key_schema objects validation'); module('Key and key_schema objects validation');
...@@ -83,26 +83,35 @@ ...@@ -83,26 +83,35 @@
}); });
test('Check the key options', function () { test("missing `key` property", function () {
var doc_list = [ stop();
var start = util.starter(1000), doc_list = [
{'identifier': 'a'} {'identifier': 'a'}
]; ];
try {
jIO.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: {}, key: {},
value: 'a' value: 'a'
}).exec(doc_list); }).exec(doc_list).then(function () {
ok(false, 'key.read_from is not checked'); ok(false, 'key.read_from is not checked');
} catch (e) { start();
}, function (e) {
equal(e.name, 'TypeError', 'wrong exception type'); equal(e.name, 'TypeError', 'wrong exception type');
equal(e.message, equal(e.message,
"Custom key is missing the read_from property", "Custom key is missing the read_from property",
'wrong exception message'); 'wrong exception message');
} start();
});
});
test("`key` has unknown property", function () {
stop();
var start = util.starter(1000), doc_list = [
{"identifier": "a"}
];
try {
jIO.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: { key: {
...@@ -110,14 +119,16 @@ ...@@ -110,14 +119,16 @@
foobar: '' foobar: ''
}, },
value: 'a' value: 'a'
}).exec(doc_list); }).exec(doc_list).then(function () {
ok(false, 'unknown key properties are not checked'); ok(false, 'unknown key properties are not checked');
} catch (e) { start();
}, function (e) {
equal(e.name, 'TypeError', 'wrong exception type'); equal(e.name, 'TypeError', 'wrong exception type');
equal(e.message, equal(e.message,
"Custom key has unknown property 'foobar'", "Custom key has unknown property 'foobar'",
'wrong exception message'); 'wrong exception message');
} start();
});
}); });
})); }));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment