]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/tidep0084.git/blob - example/iot-gateway/node_modules/smartobject/test/smartObject.signature.test.js
Initial commit
[apps/tidep0084.git] / example / iot-gateway / node_modules / smartobject / test / smartObject.signature.test.js
1 var expect = require('chai').expect, 
2     SmartObject = require('../index.js'); 
4 var smartObj = new SmartObject();
6 describe('Smart Object - Signature Check', function () {
7     describe('#.init()', function () {
8         it('should be a function', function () {
9             expect(smartObj.init).to.be.a('function');
10         });
12         it('should throw TypeError if oid is not a string or a number', function () {
13             expect(function () { return smartObj.init(); }).to.throw(TypeError);
14             expect(function () { return smartObj.init(undefined); }).to.throw(TypeError);
15             expect(function () { return smartObj.init(null); }).to.throw(TypeError);
16             expect(function () { return smartObj.init(NaN); }).to.throw(TypeError);
17             expect(function () { return smartObj.init([]); }).to.throw(TypeError);
18             expect(function () { return smartObj.init({}); }).to.throw(TypeError);
19             expect(function () { return smartObj.init(true); }).to.throw(TypeError);
20             expect(function () { return smartObj.init(new Date()); }).to.throw(TypeError);
21             expect(function () { return smartObj.init(function () {}); }).to.throw(TypeError);
22         });
24         it('should throw TypeError if iid is not a string or a number', function () {
25             expect(function () { return smartObj.init(3302); }).to.throw(TypeError);
26             expect(function () { return smartObj.init(3302, undefined); }).to.throw(TypeError);
27             expect(function () { return smartObj.init(3302, null); }).to.throw(TypeError);
28             expect(function () { return smartObj.init(3302, NaN); }).to.throw(TypeError);
29             expect(function () { return smartObj.init(3302, []); }).to.throw(TypeError);
30             expect(function () { return smartObj.init(3302, {}); }).to.throw(TypeError);
31             expect(function () { return smartObj.init(3302, true); }).to.throw(TypeError);
32             expect(function () { return smartObj.init(3302, new Date()); }).to.throw(TypeError);
33             expect(function () { return smartObj.init(3302, function () {}); }).to.throw(TypeError);
34         });
36         it('should throw TypeError if resrcs is not an object', function () {
37             expect(function () { return smartObj.init(3302, 1, undefined); }).to.throw(TypeError);
38             expect(function () { return smartObj.init(3302, 2, null); }).to.throw(TypeError);
39             expect(function () { return smartObj.init(3302, 3, NaN); }).to.throw(TypeError);
40             expect(function () { return smartObj.init(3302, 4, 10); }).to.throw(TypeError);
41             expect(function () { return smartObj.init(3302, 5, 'xx'); }).to.throw(TypeError);
42             expect(function () { return smartObj.init(3302, 6, []); }).to.throw(TypeError);
43             expect(function () { return smartObj.init(3302, 7, true); }).to.throw(TypeError);
44             expect(function () { return smartObj.init(3302, 8, new Date()); }).to.throw(TypeError);
45             expect(function () { return smartObj.init(3302, 9, function () {}); }).to.throw(TypeError);
47             expect(function () { return smartObj.init(3302, 0, {}); }).not.to.throw(TypeError);
48         });
50         it('should throw TypeError if given opt is not an object', function () {
51             expect(function () { return smartObj.init(3302, 11, {}, 10); }).to.throw(TypeError);
52             expect(function () { return smartObj.init(3302, 12, {}, 'xx'); }).to.throw(TypeError);
53             expect(function () { return smartObj.init(3302, 13, {}, []); }).to.throw(TypeError);
54             expect(function () { return smartObj.init(3302, 14, {}, true); }).to.throw(TypeError);
55             expect(function () { return smartObj.init(3302, 15, {}, new Date()); }).to.throw(TypeError);
56             expect(function () { return smartObj.init(3302, 16, {}, function () {}); }).to.throw(TypeError);
58             expect(function () { return smartObj.init(3302, 17, {}, {}); }).not.to.throw(TypeError);
59         });
61         it('should throw TypeError if iid is not a number when ipsoOnly is true', function () {
62             expect(function () { return smartObj.init(3304, 'x', {}, { ipsoOnly: true }); }).to.throw(TypeError);
63         });
65         it('should throw Error if oid is not in an IPSO-defined when ipsoOnly is true', function () {
66             expect(function () { return smartObj.init(9453, 0, {}, { ipsoOnly: true }); }).to.throw(Error);
67         });
69         it('should throw Error if rid is not in an IPSO-defined when ipsoOnly is true', function () {
70             expect(function () { return smartObj.init(3304, 0, { 9999: 20 }, { ipsoOnly: true }); }).to.throw(Error);
71         });
72     });
74     describe('#.create()', function () {
75         it('should be a function', function () {
76             expect(smartObj.create).to.be.a('function');
77         });
79         it('should throw TypeError if oid is not a string or a number', function () {
80             expect(function () { return smartObj.create(); }).to.throw(TypeError);
81             expect(function () { return smartObj.create(undefined); }).to.throw(TypeError);
82             expect(function () { return smartObj.create(null); }).to.throw(TypeError);
83             expect(function () { return smartObj.create(NaN); }).to.throw(TypeError);
84             expect(function () { return smartObj.create([]); }).to.throw(TypeError);
85             expect(function () { return smartObj.create({}); }).to.throw(TypeError);
86             expect(function () { return smartObj.create(true); }).to.throw(TypeError);
87             expect(function () { return smartObj.create(new Date()); }).to.throw(TypeError);
88             expect(function () { return smartObj.create(function () {}); }).to.throw(TypeError);
89         });
91         it('should throw TypeError if iid is not a string or a number', function () {
92             expect(function () { return smartObj.create(3304); }).to.throw(TypeError);
93             expect(function () { return smartObj.create(3304, undefined); }).to.throw(TypeError);
94             expect(function () { return smartObj.create(3304, null); }).to.throw(TypeError);
95             expect(function () { return smartObj.create(3304, NaN); }).to.throw(TypeError);
96             expect(function () { return smartObj.create(3304, []); }).to.throw(TypeError);
97             expect(function () { return smartObj.create(3304, {}); }).to.throw(TypeError);
98             expect(function () { return smartObj.create(3304, true); }).to.throw(TypeError);
99             expect(function () { return smartObj.create(3304, new Date()); }).to.throw(TypeError);
100             expect(function () { return smartObj.create(3304, function () {}); }).to.throw(TypeError);
102             expect(function () { return smartObj.create(3304, 2); }).not.to.throw(TypeError);
103             expect(function () { return smartObj.create(3304, 'b'); }).not.to.throw(TypeError);
104         });
106         it('should throw TypeError if given opt is not an object', function () {
107             expect(function () { return smartObj.create(3304, 3, 10); }).to.throw(TypeError);
108             expect(function () { return smartObj.create(3304, 3, 'xx'); }).to.throw(TypeError);
109             expect(function () { return smartObj.create(3304, 3, []); }).to.throw(TypeError);
110             expect(function () { return smartObj.create(3304, 3, true); }).to.throw(TypeError);
111             expect(function () { return smartObj.create(3304, 3, new Date()); }).to.throw(TypeError);
112             expect(function () { return smartObj.create(3304, 3, function () {}); }).to.throw(TypeError);
114             expect(function () { return smartObj.create(3304, 3, {}); }).not.to.throw(TypeError);
115         });
117         it('should throw TypeError if iid is not a number when ipsoOnly is true', function () {
118             expect(function () { return smartObj.create(3304, 'x', { ipsoOnly: true }); }).to.throw(TypeError);
119         });
121         it('should throw Error if oid is not in an IPSO-defined when ipsoOnly is true', function () {
122             expect(function () { return smartObj.create(9453, 0, { ipsoOnly: true }); }).to.throw(Error);
123         });
124     });
126     describe('#.objectList()', function () {
127         it('should be a function', function () {
128             expect(smartObj.objectList).to.be.a('function');
129         });
130     });
132     describe('#.has()', function () {
133         it('should be a function', function () {
134             expect(smartObj.has).to.be.a('function');
135         });
137         it('should throw TypeError if input oid is not a number and not a string', function () {
138             expect(function () { return smartObj.has(); }).to.throw(TypeError);
139             expect(function () { return smartObj.has(undefined, '1', 'a'); }).to.throw(TypeError);
140             expect(function () { return smartObj.has(null, '1', 'a'); }).to.throw(TypeError);
141             expect(function () { return smartObj.has(NaN, '1', 'a'); }).to.throw(TypeError);
142             expect(function () { return smartObj.has([], '1', 'a'); }).to.throw(TypeError);
143             expect(function () { return smartObj.has({}, '1', 'a'); }).to.throw(TypeError);
144             expect(function () { return smartObj.has(true, '1', 'a'); }).to.throw(TypeError);
145             expect(function () { return smartObj.has(new Date(), '1', 'a'); }).to.throw(TypeError);
146             expect(function () { return smartObj.has(function () {}, '1', 'a'); }).to.throw(TypeError);
147         });
149         it('should throw TypeError if input iid is not a number and not a string', function () {
150             smartObj.init(3303, 0, {});
151             expect(function () { return smartObj.has(3303, null, 'a'); }).to.throw(TypeError);
152             expect(function () { return smartObj.has(3303, NaN, 'a'); }).to.throw(TypeError);
153             expect(function () { return smartObj.has(3303, [], 'a'); }).to.throw(TypeError);
154             expect(function () { return smartObj.has(3303, {}, 'a'); }).to.throw(TypeError);
155             expect(function () { return smartObj.has(3303, true, 'a'); }).to.throw(TypeError);
156             expect(function () { return smartObj.has(3303, new Date(), 'a'); }).to.throw(TypeError);
157             expect(function () { return smartObj.has(3303, function () {}, 'a'); }).to.throw(TypeError);
159         });
161         it('should throw TypeError if input rid is not a number and not a string', function () {
162             expect(function () { return smartObj.has(3303, 0, null); }).to.throw(TypeError);
163             expect(function () { return smartObj.has(3303, 0, NaN); }).to.throw(TypeError);
164             expect(function () { return smartObj.has(3303, 0, []); }).to.throw(TypeError);
165             expect(function () { return smartObj.has(3303, 0, {}); }).to.throw(TypeError);
166             expect(function () { return smartObj.has(3303, 0, true); }).to.throw(TypeError);
167             expect(function () { return smartObj.has(3303, 0, new Date()); }).to.throw(TypeError);
168             expect(function () { return smartObj.has(3303, 0, function () {}); }).to.throw(TypeError);
169         });
170     });
172     describe('#.findObject()', function () {
173         it('should be a function', function () {
174             expect(smartObj.findObject).to.be.a('function');
175         });
177         it('should throw TypeError if oid is not a string or a number', function () {
178             expect(function () { return smartObj.findObject(); }).to.throw(TypeError);
179             expect(function () { return smartObj.findObject(undefined); }).to.throw(TypeError);
180             expect(function () { return smartObj.findObject(null); }).to.throw(TypeError);
181             expect(function () { return smartObj.findObject(NaN); }).to.throw(TypeError);
182             expect(function () { return smartObj.findObject([]); }).to.throw(TypeError);
183             expect(function () { return smartObj.findObject({}); }).to.throw(TypeError);
184             expect(function () { return smartObj.findObject(true); }).to.throw(TypeError);
185             expect(function () { return smartObj.findObject(new Date()); }).to.throw(TypeError);
186             expect(function () { return smartObj.findObject(function () {}); }).to.throw(TypeError);
188             expect(function () { return smartObj.findObject(5700); }).not.to.throw(TypeError);
189             expect(function () { return smartObj.findObject('temperature'); }).not.to.throw(TypeError);
190         });
191     });
193     describe('#.findObjectInstance()', function () {
194         it('should be a function', function () {
195             expect(smartObj.findObjectInstance).to.be.a('function');
196         });
198         it('should throw TypeError if oid is not a string or a number', function () {
199             expect(function () { return smartObj.findObjectInstance(); }).to.throw(TypeError);
200             expect(function () { return smartObj.findObjectInstance(undefined); }).to.throw(TypeError);
201             expect(function () { return smartObj.findObjectInstance(null); }).to.throw(TypeError);
202             expect(function () { return smartObj.findObjectInstance(NaN); }).to.throw(TypeError);
203             expect(function () { return smartObj.findObjectInstance([]); }).to.throw(TypeError);
204             expect(function () { return smartObj.findObjectInstance({}); }).to.throw(TypeError);
205             expect(function () { return smartObj.findObjectInstance(true); }).to.throw(TypeError);
206             expect(function () { return smartObj.findObjectInstance(new Date()); }).to.throw(TypeError);
207             expect(function () { return smartObj.findObjectInstance(function () {}); }).to.throw(TypeError);
208         });
210         it('should throw TypeError if iid is not a string or a number', function () {
211             expect(function () { return smartObj.findObjectInstance(5700); }).to.throw(TypeError);
212             expect(function () { return smartObj.findObjectInstance(5700, undefined); }).to.throw(TypeError);
213             expect(function () { return smartObj.findObjectInstance(5700, null); }).to.throw(TypeError);
214             expect(function () { return smartObj.findObjectInstance(5700, NaN); }).to.throw(TypeError);
215             expect(function () { return smartObj.findObjectInstance(5700, []); }).to.throw(TypeError);
216             expect(function () { return smartObj.findObjectInstance(5700, {}); }).to.throw(TypeError);
217             expect(function () { return smartObj.findObjectInstance(5700, true); }).to.throw(TypeError);
218             expect(function () { return smartObj.findObjectInstance(5700, new Date()); }).to.throw(TypeError);
219             expect(function () { return smartObj.findObjectInstance(5700, function () {}); }).to.throw(TypeError);
221             expect(function () { return smartObj.findObjectInstance(5700, 0); }).not.to.throw(TypeError);
222             expect(function () { return smartObj.findObjectInstance(5700, 'xx'); }).not.to.throw(TypeError);
223         });
224     });
226     describe('#.isReadable()', function () {
227         it('should be a function', function () {
228             expect(smartObj.isReadable).to.be.a('function');
229         });
231         it('should throw TypeError if input oid is not a number and not a string', function () {
232             expect(function () { return smartObj.isReadable(); }).to.throw(TypeError);
233             expect(function () { return smartObj.isReadable(undefined, '1', 'a'); }).to.throw(TypeError);
234             expect(function () { return smartObj.isReadable(null, '1', 'a'); }).to.throw(TypeError);
235             expect(function () { return smartObj.isReadable(NaN, '1', 'a'); }).to.throw(TypeError);
236             expect(function () { return smartObj.isReadable([], '1', 'a'); }).to.throw(TypeError);
237             expect(function () { return smartObj.isReadable({}, '1', 'a'); }).to.throw(TypeError);
238             expect(function () { return smartObj.isReadable(true, '1', 'a'); }).to.throw(TypeError);
239             expect(function () { return smartObj.isReadable(new Date(), '1', 'a'); }).to.throw(TypeError);
240             expect(function () { return smartObj.isReadable(function () {}, '1', 'a'); }).to.throw(TypeError);
241         });
243         it('should throw TypeError if input iid is not a number and not a string', function () {
244             expect(function () { return smartObj.isReadable(3303); }).to.throw(TypeError);
245             expect(function () { return smartObj.isReadable(3303, undefined, 'a'); }).to.throw(TypeError);
246             expect(function () { return smartObj.isReadable(3303, null, 'a'); }).to.throw(TypeError);
247             expect(function () { return smartObj.isReadable(3303, NaN, 'a'); }).to.throw(TypeError);
248             expect(function () { return smartObj.isReadable(3303, [], 'a'); }).to.throw(TypeError);
249             expect(function () { return smartObj.isReadable(3303, {}, 'a'); }).to.throw(TypeError);
250             expect(function () { return smartObj.isReadable(3303, true, 'a'); }).to.throw(TypeError);
251             expect(function () { return smartObj.isReadable(3303, new Date(), 'a'); }).to.throw(TypeError);
252             expect(function () { return smartObj.isReadable(3303, function () {}, 'a'); }).to.throw(TypeError);
254         });
256         it('should throw TypeError if input rid is not a number and not a string', function () {
257             smartObj.init(3303, 1, {});
258             expect(function () { return smartObj.isReadable(3303, 1); }).to.throw(TypeError);
259             expect(function () { return smartObj.isReadable(3303, 1, undefined); }).to.throw(TypeError);
260             expect(function () { return smartObj.isReadable(3303, 1, null); }).to.throw(TypeError);
261             expect(function () { return smartObj.isReadable(3303, 1, NaN); }).to.throw(TypeError);
262             expect(function () { return smartObj.isReadable(3303, 1, []); }).to.throw(TypeError);
263             expect(function () { return smartObj.isReadable(3303, 1, {}); }).to.throw(TypeError);
264             expect(function () { return smartObj.isReadable(3303, 1, true); }).to.throw(TypeError);
265             expect(function () { return smartObj.isReadable(3303, 1, new Date()); }).to.throw(TypeError);
266             expect(function () { return smartObj.isReadable(3303, 1, function () {}); }).to.throw(TypeError);
267         });
268     });
270     describe('#.isWritable()', function () {
271         it('should be a function', function () {
272             expect(smartObj.isWritable).to.be.a('function');
273         });
275         it('should throw TypeError if input oid is not a number and not a string', function () {
276             expect(function () { return smartObj.isWritable(); }).to.throw(TypeError);
277             expect(function () { return smartObj.isWritable(undefined, '1', 'a'); }).to.throw(TypeError);
278             expect(function () { return smartObj.isWritable(null, '1', 'a'); }).to.throw(TypeError);
279             expect(function () { return smartObj.isWritable(NaN, '1', 'a'); }).to.throw(TypeError);
280             expect(function () { return smartObj.isWritable([], '1', 'a'); }).to.throw(TypeError);
281             expect(function () { return smartObj.isWritable({}, '1', 'a'); }).to.throw(TypeError);
282             expect(function () { return smartObj.isWritable(true, '1', 'a'); }).to.throw(TypeError);
283             expect(function () { return smartObj.isWritable(new Date(), '1', 'a'); }).to.throw(TypeError);
284             expect(function () { return smartObj.isWritable(function () {}, '1', 'a'); }).to.throw(TypeError);
285         });
287         it('should throw TypeError if input iid is not a number and not a string', function () {
288             expect(function () { return smartObj.isWritable(3303); }).to.throw(TypeError);
289             expect(function () { return smartObj.isWritable(3303, undefined, 'a'); }).to.throw(TypeError);
290             expect(function () { return smartObj.isWritable(3303, null, 'a'); }).to.throw(TypeError);
291             expect(function () { return smartObj.isWritable(3303, NaN, 'a'); }).to.throw(TypeError);
292             expect(function () { return smartObj.isWritable(3303, [], 'a'); }).to.throw(TypeError);
293             expect(function () { return smartObj.isWritable(3303, {}, 'a'); }).to.throw(TypeError);
294             expect(function () { return smartObj.isWritable(3303, true, 'a'); }).to.throw(TypeError);
295             expect(function () { return smartObj.isWritable(3303, new Date(), 'a'); }).to.throw(TypeError);
296             expect(function () { return smartObj.isWritable(3303, function () {}, 'a'); }).to.throw(TypeError);
298         });
300         it('should throw TypeError if input rid is not a number and not a string', function () {
301             expect(function () { return smartObj.isWritable(3303, 1); }).to.throw(TypeError);
302             expect(function () { return smartObj.isWritable(3303, 1, undefined); }).to.throw(TypeError);
303             expect(function () { return smartObj.isWritable(3303, 1, null); }).to.throw(TypeError);
304             expect(function () { return smartObj.isWritable(3303, 1, NaN); }).to.throw(TypeError);
305             expect(function () { return smartObj.isWritable(3303, 1, []); }).to.throw(TypeError);
306             expect(function () { return smartObj.isWritable(3303, 1, {}); }).to.throw(TypeError);
307             expect(function () { return smartObj.isWritable(3303, 1, true); }).to.throw(TypeError);
308             expect(function () { return smartObj.isWritable(3303, 1, new Date()); }).to.throw(TypeError);
309             expect(function () { return smartObj.isWritable(3303, 1, function () {}); }).to.throw(TypeError);
310         });
311     });
312     
313     describe('#.isExecutable()', function () {
314         it('should be a function', function () {
315             expect(smartObj.isExecutable).to.be.a('function');
316         });
318         it('should throw TypeError if input oid is not a number and not a string', function () {
319             expect(function () { return smartObj.isExecutable(); }).to.throw(TypeError);
320             expect(function () { return smartObj.isExecutable(undefined, '1', 'a'); }).to.throw(TypeError);
321             expect(function () { return smartObj.isExecutable(null, '1', 'a'); }).to.throw(TypeError);
322             expect(function () { return smartObj.isExecutable(NaN, '1', 'a'); }).to.throw(TypeError);
323             expect(function () { return smartObj.isExecutable([], '1', 'a'); }).to.throw(TypeError);
324             expect(function () { return smartObj.isExecutable({}, '1', 'a'); }).to.throw(TypeError);
325             expect(function () { return smartObj.isExecutable(true, '1', 'a'); }).to.throw(TypeError);
326             expect(function () { return smartObj.isExecutable(new Date(), '1', 'a'); }).to.throw(TypeError);
327             expect(function () { return smartObj.isExecutable(function () {}, '1', 'a'); }).to.throw(TypeError);
328         });
330         it('should throw TypeError if input iid is not a number and not a string', function () {
331             expect(function () { return smartObj.isExecutable(3303); }).to.throw(TypeError);
332             expect(function () { return smartObj.isExecutable(3303, undefined, 'a'); }).to.throw(TypeError);
333             expect(function () { return smartObj.isExecutable(3303, null, 'a'); }).to.throw(TypeError);
334             expect(function () { return smartObj.isExecutable(3303, NaN, 'a'); }).to.throw(TypeError);
335             expect(function () { return smartObj.isExecutable(3303, [], 'a'); }).to.throw(TypeError);
336             expect(function () { return smartObj.isExecutable(3303, {}, 'a'); }).to.throw(TypeError);
337             expect(function () { return smartObj.isExecutable(3303, true, 'a'); }).to.throw(TypeError);
338             expect(function () { return smartObj.isExecutable(3303, new Date(), 'a'); }).to.throw(TypeError);
339             expect(function () { return smartObj.isExecutable(3303, function () {}, 'a'); }).to.throw(TypeError);
341         });
343         it('should throw TypeError if input rid is not a number and not a string', function () {
344             expect(function () { return smartObj.isExecutable(3303, 1); }).to.throw(TypeError);
345             expect(function () { return smartObj.isExecutable(3303, 1, undefined); }).to.throw(TypeError);
346             expect(function () { return smartObj.isExecutable(3303, 1, null); }).to.throw(TypeError);
347             expect(function () { return smartObj.isExecutable(3303, 1, NaN); }).to.throw(TypeError);
348             expect(function () { return smartObj.isExecutable(3303, 1, []); }).to.throw(TypeError);
349             expect(function () { return smartObj.isExecutable(3303, 1, {}); }).to.throw(TypeError);
350             expect(function () { return smartObj.isExecutable(3303, 1, true); }).to.throw(TypeError);
351             expect(function () { return smartObj.isExecutable(3303, 1, new Date()); }).to.throw(TypeError);
352             expect(function () { return smartObj.isExecutable(3303, 1, function () {}); }).to.throw(TypeError);
353         });
354     });
356     describe('#.get()', function () {
357         it('should be a function', function () {
358             expect(smartObj.get).to.be.a('function');
359         });
361         it('should throw TypeError if input oid is not a number and not a string', function () {
362             expect(function () { return smartObj.get(); }).to.throw(TypeError);
363             expect(function () { return smartObj.get(undefined, '1', 'a'); }).to.throw(TypeError);
364             expect(function () { return smartObj.get(null, '1', 'a'); }).to.throw(TypeError);
365             expect(function () { return smartObj.get(NaN, '1', 'a'); }).to.throw(TypeError);
366             expect(function () { return smartObj.get([], '1', 'a'); }).to.throw(TypeError);
367             expect(function () { return smartObj.get({}, '1', 'a'); }).to.throw(TypeError);
368             expect(function () { return smartObj.get(true, '1', 'a'); }).to.throw(TypeError);
369             expect(function () { return smartObj.get(new Date(), '1', 'a'); }).to.throw(TypeError);
370             expect(function () { return smartObj.get(function () {}, '1', 'a'); }).to.throw(TypeError);
371         });
373         it('should throw TypeError if input iid is not a number and not a string', function () {
374             expect(function () { return smartObj.get(3303); }).to.throw(TypeError);
375             expect(function () { return smartObj.get(3303, undefined, 'a'); }).to.throw(TypeError);
376             expect(function () { return smartObj.get(3303, null, 'a'); }).to.throw(TypeError);
377             expect(function () { return smartObj.get(3303, NaN, 'a'); }).to.throw(TypeError);
378             expect(function () { return smartObj.get(3303, [], 'a'); }).to.throw(TypeError);
379             expect(function () { return smartObj.get(3303, {}, 'a'); }).to.throw(TypeError);
380             expect(function () { return smartObj.get(3303, true, 'a'); }).to.throw(TypeError);
381             expect(function () { return smartObj.get(3303, new Date(), 'a'); }).to.throw(TypeError);
382             expect(function () { return smartObj.get(3303, function () {}, 'a'); }).to.throw(TypeError);
384         });
386         it('should throw TypeError if input rid is not a number and not a string', function () {
387             expect(function () { return smartObj.get(3303, 1); }).to.throw(TypeError);
388             expect(function () { return smartObj.get(3303, 1, undefined); }).to.throw(TypeError);
389             expect(function () { return smartObj.get(3303, 1, null); }).to.throw(TypeError);
390             expect(function () { return smartObj.get(3303, 1, NaN); }).to.throw(TypeError);
391             expect(function () { return smartObj.get(3303, 1, []); }).to.throw(TypeError);
392             expect(function () { return smartObj.get(3303, 1, {}); }).to.throw(TypeError);
393             expect(function () { return smartObj.get(3303, 1, true); }).to.throw(TypeError);
394             expect(function () { return smartObj.get(3303, 1, new Date()); }).to.throw(TypeError);
395             expect(function () { return smartObj.get(3303, 1, function () {}); }).to.throw(TypeError);
396         });
397     });
399     describe('#.set()', function () {
400         it('should be a function', function () {
401             expect(smartObj.set).to.be.a('function');
402         });
404         it('should throw TypeError if input oid is not a number and not a string', function () {
405             expect(function () { return smartObj.set(); }).to.throw(TypeError);
406             expect(function () { return smartObj.set(undefined, '1', 'a', 'xx'); }).to.throw(TypeError);
407             expect(function () { return smartObj.set(null, '1', 'a', 'xx'); }).to.throw(TypeError);
408             expect(function () { return smartObj.set(NaN, '1', 'a', 'xx'); }).to.throw(TypeError);
409             expect(function () { return smartObj.set([], '1', 'a', 'xx'); }).to.throw(TypeError);
410             expect(function () { return smartObj.set({}, '1', 'a', 'xx'); }).to.throw(TypeError);
411             expect(function () { return smartObj.set(true, '1', 'a', 'xx'); }).to.throw(TypeError);
412             expect(function () { return smartObj.set(new Date(), '1', 'a', 'xx'); }).to.throw(TypeError);
413             expect(function () { return smartObj.set(function () {}, '1', 'a', 'xx'); }).to.throw(TypeError);
414         });
416         it('should throw TypeError if input iid is not a number and not a string', function () {
417             expect(function () { return smartObj.set(3303); }).to.throw(TypeError);
418             expect(function () { return smartObj.set(3303, undefined, 'a', 'xx'); }).to.throw(TypeError);
419             expect(function () { return smartObj.set(3303, null, 'a', 'xx'); }).to.throw(TypeError);
420             expect(function () { return smartObj.set(3303, NaN, 'a', 'xx'); }).to.throw(TypeError);
421             expect(function () { return smartObj.set(3303, [], 'a', 'xx'); }).to.throw(TypeError);
422             expect(function () { return smartObj.set(3303, {}, 'a', 'xx'); }).to.throw(TypeError);
423             expect(function () { return smartObj.set(3303, true, 'a', 'xx'); }).to.throw(TypeError);
424             expect(function () { return smartObj.set(3303, new Date(), 'a', 'xx'); }).to.throw(TypeError);
425             expect(function () { return smartObj.set(3303, function () {}, 'a', 'xx'); }).to.throw(TypeError);
427         });
429         it('should throw TypeError if input rid is not a number and not a string', function () {
430             smartObj.init(3303, 2, {});
431             expect(function () { return smartObj.set(3303, 2); }).to.throw(TypeError);
432             expect(function () { return smartObj.set(3303, 2, undefined, 'xx'); }).to.throw(TypeError);
433             expect(function () { return smartObj.set(3303, 2, null, 'xx'); }).to.throw(TypeError);
434             expect(function () { return smartObj.set(3303, 2, NaN, 'xx'); }).to.throw(TypeError);
435             expect(function () { return smartObj.set(3303, 2, [], 'xx'); }).to.throw(TypeError);
436             expect(function () { return smartObj.set(3303, 2, {}, 'xx'); }).to.throw(TypeError);
437             expect(function () { return smartObj.set(3303, 2, true, 'xx'); }).to.throw(TypeError);
438             expect(function () { return smartObj.set(3303, 2, new Date(), 'xx'); }).to.throw(TypeError);
439             expect(function () { return smartObj.set(3303, 2, function () {}, 'xx'); }).to.throw(TypeError);
440         });
442         it('should throw TypeError if value is undefined or a function', function () {
443             expect(function () { return smartObj.set(3303, 2, 5700, undefined); }).to.throw(TypeError);
444             expect(function () { return smartObj.set(3303, 2, 5700, function () {}); }).to.throw(TypeError);
446             expect(function () { return smartObj.set(3303, 2, 5700, null); }).not.to.throw(TypeError);
447             expect(function () { return smartObj.set(3303, 2, 5700, NaN); }).not.to.throw(TypeError);
448             expect(function () { return smartObj.set(3303, 2, 5700, []); }).not.to.throw(TypeError);
449             expect(function () { return smartObj.set(3303, 2, 5700, {}); }).not.to.throw(TypeError);
450             expect(function () { return smartObj.set(3303, 2, 5700, true); }).not.to.throw(TypeError);
451             expect(function () { return smartObj.set(3303, 2, 5700, new Date()); }).not.to.throw(TypeError);
452         });
453     });
455     describe('#.dumpSync()', function () {
456         it('should be a function', function () {
457             expect(smartObj.dumpSync).to.be.a('function');
458         });
460         it('should throw TypeError if oid is not a string or a number', function () {
461             expect(function () { return smartObj.dumpSync(undefined); }).to.throw(TypeError);
462             expect(function () { return smartObj.dumpSync(null); }).to.throw(TypeError);
463             expect(function () { return smartObj.dumpSync(NaN); }).to.throw(TypeError);
464             expect(function () { return smartObj.dumpSync([]); }).to.throw(TypeError);
465             expect(function () { return smartObj.dumpSync({}); }).to.throw(TypeError);
466             expect(function () { return smartObj.dumpSync(true); }).to.throw(TypeError);
467             expect(function () { return smartObj.dumpSync(new Date()); }).to.throw(TypeError);
468             expect(function () { return smartObj.dumpSync(function () {}); }).to.throw(TypeError);
470             expect(function () { return smartObj.dumpSync(3303); }).not.to.throw(TypeError);
471             expect(function () { return smartObj.dumpSync('temperature'); }).not.to.throw(TypeError);
472         });
474         it('should throw TypeError if iid is not a string or a number', function () {
475             expect(function () { return smartObj.dumpSync(3303, undefined); }).to.throw(TypeError);
476             expect(function () { return smartObj.dumpSync(3303, null); }).to.throw(TypeError);
477             expect(function () { return smartObj.dumpSync(3303, NaN); }).to.throw(TypeError);
478             expect(function () { return smartObj.dumpSync(3303, []); }).to.throw(TypeError);
479             expect(function () { return smartObj.dumpSync(3303, {}); }).to.throw(TypeError);
480             expect(function () { return smartObj.dumpSync(3303, true); }).to.throw(TypeError);
481             expect(function () { return smartObj.dumpSync(3303, new Date()); }).to.throw(TypeError);
482             expect(function () { return smartObj.dumpSync(3303, function () {}); }).to.throw(TypeError);
484             expect(function () { return smartObj.dumpSync(3303, 0); }).not.to.throw(TypeError);
485             expect(function () { return smartObj.dumpSync(3303, 'xx'); }).not.to.throw(TypeError);
486         });
487     });
489     describe('#.dump()', function () {
490         it('should be a function', function () {
491             expect(smartObj.dump).to.be.a('function');
492         });
494         it('should throw TypeError if callback is not a function', function () {
495             expect(function () { return smartObj.dump(); }).to.throw(Error);
496             expect(function () { return smartObj.dump(undefined); }).to.throw(TypeError);
497             expect(function () { return smartObj.dump(null); }).to.throw(TypeError);
498             expect(function () { return smartObj.dump(NaN); }).to.throw(TypeError);
499             expect(function () { return smartObj.dump(10); }).to.throw(TypeError);
500             expect(function () { return smartObj.dump('xx'); }).to.throw(TypeError);
501             expect(function () { return smartObj.dump([]); }).to.throw(TypeError);
502             expect(function () { return smartObj.dump({}); }).to.throw(TypeError);
503             expect(function () { return smartObj.dump(true); }).to.throw(TypeError);
504             expect(function () { return smartObj.dump(new Date()); }).to.throw(TypeError);
506             expect(function () { return smartObj.dump(function () {}); }).not.to.throw(TypeError);
507         });
509         it('should throw TypeError if oid is not a string or a number', function () {
510             expect(function () { return smartObj.dump(undefined, function () {}); }).to.throw(TypeError);
511             expect(function () { return smartObj.dump(null, function () {}); }).to.throw(TypeError);
512             expect(function () { return smartObj.dump(NaN, function () {}); }).to.throw(TypeError);
513             expect(function () { return smartObj.dump([], function () {}); }).to.throw(TypeError);
514             expect(function () { return smartObj.dump({}, function () {}); }).to.throw(TypeError);
515             expect(function () { return smartObj.dump(true, function () {}); }).to.throw(TypeError);
516             expect(function () { return smartObj.dump(new Date(), function () {}); }).to.throw(TypeError);
517             expect(function () { return smartObj.dump(function () {}, function () {}); }).to.throw(TypeError);
519             expect(function () { return smartObj.dump(3303, function () {}, {}); }).not.to.throw(TypeError);
520         });
522         it('should throw TypeError if iid is not a string or a number', function () {
523             expect(function () { return smartObj.dump(3303, undefined, function () {}); }).to.throw(TypeError);
524             expect(function () { return smartObj.dump(3303, null, function () {}); }).to.throw(TypeError);
525             expect(function () { return smartObj.dump(3303, NaN, function () {}); }).to.throw(TypeError);
526             expect(function () { return smartObj.dump(3303, [], function () {}); }).to.throw(TypeError);
527             expect(function () { return smartObj.dump(3303, {}, function () {}); }).to.throw(TypeError);
528             expect(function () { return smartObj.dump(3303, true, function () {}); }).to.throw(TypeError);
529             expect(function () { return smartObj.dump(3303, new Date(), function () {}); }).to.throw(TypeError);
530             expect(function () { return smartObj.dump(3303, function () {}, function () {}); }).to.throw(TypeError);
532             expect(function () { return smartObj.dump(3303, 0, function () {}, {}); }).not.to.throw(TypeError);
533         });
535         it('should throw TypeError if given opt is not an object', function () {
536             expect(function () { return smartObj.dump(3303, 2, function () {}, 10); }).to.throw(TypeError);
537             expect(function () { return smartObj.dump(3303, 2, function () {}, 'xx'); }).to.throw(TypeError);
538             expect(function () { return smartObj.dump(3303, 2, function () {}, []); }).to.throw(TypeError);
539             expect(function () { return smartObj.dump(3303, 2, function () {}, true); }).to.throw(TypeError);
540             expect(function () { return smartObj.dump(3303, 2, function () {}, new Date()); }).to.throw(TypeError);
541             expect(function () { return smartObj.dump(3303, 2, function () {}, function () {}); }).to.throw(TypeError);
543             expect(function () { return smartObj.dump(3303, 2, function () {}, {}); }).not.to.throw(TypeError);
544         });
545     });
547     describe('#.read()', function () {
548         it('should be a function', function () {
549             expect(smartObj.read).to.be.a('function');
550         });
552         it('should throw TypeError if oid is not a string or a number', function () {
553             expect(function () { return smartObj.read(); }).to.throw(TypeError);
554             expect(function () { return smartObj.read(undefined); }).to.throw(TypeError);
555             expect(function () { return smartObj.read(null); }).to.throw(TypeError);
556             expect(function () { return smartObj.read(NaN); }).to.throw(TypeError);
557             expect(function () { return smartObj.read([]); }).to.throw(TypeError);
558             expect(function () { return smartObj.read({}); }).to.throw(TypeError);
559             expect(function () { return smartObj.read(true); }).to.throw(TypeError);
560             expect(function () { return smartObj.read(new Date()); }).to.throw(TypeError);
561             expect(function () { return smartObj.read(function () {}); }).to.throw(TypeError);
562         });
564         it('should throw TypeError if iid is not a string or a number', function () {
565             expect(function () { return smartObj.read(3303); }).to.throw(TypeError);
566             expect(function () { return smartObj.read(3303, undefined); }).to.throw(TypeError);
567             expect(function () { return smartObj.read(3303, null); }).to.throw(TypeError);
568             expect(function () { return smartObj.read(3303, NaN); }).to.throw(TypeError);
569             expect(function () { return smartObj.read(3303, []); }).to.throw(TypeError);
570             expect(function () { return smartObj.read(3303, {}); }).to.throw(TypeError);
571             expect(function () { return smartObj.read(3303, true); }).to.throw(TypeError);
572             expect(function () { return smartObj.read(3303, new Date()); }).to.throw(TypeError);
573             expect(function () { return smartObj.read(3303, function () {}); }).to.throw(TypeError);
574         });
576         it('should throw TypeError if rid is not a string or a number', function () {
577             expect(function () { return smartObj.read(3303, 2); }).to.throw(TypeError);
578             expect(function () { return smartObj.read(3303, 2, undefined); }).to.throw(TypeError);
579             expect(function () { return smartObj.read(3303, 2, null); }).to.throw(TypeError);
580             expect(function () { return smartObj.read(3303, 2, NaN); }).to.throw(TypeError);
581             expect(function () { return smartObj.read(3303, 2, []); }).to.throw(TypeError);
582             expect(function () { return smartObj.read(3303, 2, {}); }).to.throw(TypeError);
583             expect(function () { return smartObj.read(3303, 2, true); }).to.throw(TypeError);
584             expect(function () { return smartObj.read(3303, 2, new Date()); }).to.throw(TypeError);
585             expect(function () { return smartObj.read(3303, 2, function () {}); }).to.throw(TypeError);
587             expect(function () { return smartObj.read(3303, 2, 5700); }).not.to.throw(TypeError);
588             expect(function () { return smartObj.read(3303, 2, 'temperature'); }).not.to.throw(TypeError);
589         });
591         it('should throw TypeError if given opt is not an object', function () {
592             expect(function () { return smartObj.read(3303, 2, 5700, function () {}, 10); }).to.throw(TypeError);
593             expect(function () { return smartObj.read(3303, 2, 5700, function () {}, 'xx'); }).to.throw(TypeError);
594             expect(function () { return smartObj.read(3303, 2, 5700, function () {}, []); }).to.throw(TypeError);
595             expect(function () { return smartObj.read(3303, 2, 5700, function () {}, true); }).to.throw(TypeError);
596             expect(function () { return smartObj.read(3303, 2, 5700, function () {}, new Date()); }).to.throw(TypeError);
597             expect(function () { return smartObj.read(3303, 2, 5700, function () {}, function () {}); }).to.throw(TypeError);
599             expect(function () { return smartObj.read(3303, 2, 5700, function () {}, {}); }).not.to.throw(TypeError);
600         });
601     });
603     describe('#.write()', function () {
604         it('should be a function', function () {
605             expect(smartObj.write).to.be.a('function');
606         });
608         it('should throw TypeError if oid is not a string or a number', function () {
609             expect(function () { return smartObj.write(); }).to.throw(TypeError);
610             expect(function () { return smartObj.write(undefined); }).to.throw(TypeError);
611             expect(function () { return smartObj.write(null); }).to.throw(TypeError);
612             expect(function () { return smartObj.write(NaN); }).to.throw(TypeError);
613             expect(function () { return smartObj.write([]); }).to.throw(TypeError);
614             expect(function () { return smartObj.write({}); }).to.throw(TypeError);
615             expect(function () { return smartObj.write(true); }).to.throw(TypeError);
616             expect(function () { return smartObj.write(new Date()); }).to.throw(TypeError);
617             expect(function () { return smartObj.write(function () {}); }).to.throw(TypeError);
618         });
620         it('should throw TypeError if iid is not a string or a number', function () {
621             expect(function () { return smartObj.write(5700); }).to.throw(TypeError);
622             expect(function () { return smartObj.write(5700, undefined); }).to.throw(TypeError);
623             expect(function () { return smartObj.write(5700, null); }).to.throw(TypeError);
624             expect(function () { return smartObj.write(5700, NaN); }).to.throw(TypeError);
625             expect(function () { return smartObj.write(5700, []); }).to.throw(TypeError);
626             expect(function () { return smartObj.write(5700, {}); }).to.throw(TypeError);
627             expect(function () { return smartObj.write(5700, true); }).to.throw(TypeError);
628             expect(function () { return smartObj.write(5700, new Date()); }).to.throw(TypeError);
629             expect(function () { return smartObj.write(5700, function () {}); }).to.throw(TypeError);
630         });
632         it('should throw TypeError if rid is not a string or a number', function () {
633             expect(function () { return smartObj.write(); }).to.throw(TypeError);
634             expect(function () { return smartObj.write(3303, 2, undefined); }).to.throw(TypeError);
635             expect(function () { return smartObj.write(3303, 2, null); }).to.throw(TypeError);
636             expect(function () { return smartObj.write(3303, 2, NaN); }).to.throw(TypeError);
637             expect(function () { return smartObj.write(3303, 2, []); }).to.throw(TypeError);
638             expect(function () { return smartObj.write(3303, 2, {}); }).to.throw(TypeError);
639             expect(function () { return smartObj.write(3303, 2, true); }).to.throw(TypeError);
640             expect(function () { return smartObj.write(3303, 2, new Date()); }).to.throw(TypeError);
641             expect(function () { return smartObj.write(3303, 2, function () {}); }).to.throw(TypeError);
643             expect(function () { return smartObj.write(3303, 2, 5700, 30); }).not.to.throw(TypeError);
644             expect(function () { return smartObj.write(3303, 2, 'temperature', 30); }).not.to.throw(TypeError);
645         });
647         it('should throw TypeError if value is undefined or a function', function () {
648             expect(function () { return smartObj.write(3303, 2, 5700, undefined); }).to.throw(TypeError);
649             expect(function () { return smartObj.write(3303, 2, 5700, function () {}); }).to.throw(TypeError);
651             expect(function () { return smartObj.write(3303, 2, 5700, null); }).not.to.throw(TypeError);
652             expect(function () { return smartObj.write(3303, 2, 5700, NaN); }).not.to.throw(TypeError);
653             expect(function () { return smartObj.write(3303, 2, 5700, []); }).not.to.throw(TypeError);
654             expect(function () { return smartObj.write(3303, 2, 5700, {}); }).not.to.throw(TypeError);
655             expect(function () { return smartObj.write(3303, 2, 5700, true); }).not.to.throw(TypeError);
656             expect(function () { return smartObj.write(3303, 2, 5700, new Date()); }).not.to.throw(TypeError);
657         });
659         it('should throw TypeError if given opt is not an object', function () {
660             expect(function () { return smartObj.write(3303, 2, 5700, 30, function () {}, 10); }).to.throw(TypeError);
661             expect(function () { return smartObj.write(3303, 2, 5700, 30, function () {}, 'xx'); }).to.throw(TypeError);
662             expect(function () { return smartObj.write(3303, 2, 5700, 30, function () {}, []); }).to.throw(TypeError);
663             expect(function () { return smartObj.write(3303, 2, 5700, 30, function () {}, true); }).to.throw(TypeError);
664             expect(function () { return smartObj.write(3303, 2, 5700, 30, function () {}, new Date()); }).to.throw(TypeError);
665             expect(function () { return smartObj.write(3303, 2, 5700, 30, function () {}, function () {}); }).to.throw(TypeError);
667             expect(function () { return smartObj.write(3303, 2, 5700, 30, function () {}, {}); }).not.to.throw(TypeError);
668         });
669     });
671     describe('#.exec()', function () {
672         it('should be a function', function () {
673             expect(smartObj.exec).to.be.a('function');
674         });
676         it('should throw TypeError if oid is not a string or a number', function () {
677             expect(function () { return smartObj.exec(); }).to.throw(TypeError);
678             expect(function () { return smartObj.exec(undefined); }).to.throw(TypeError);
679             expect(function () { return smartObj.exec(null); }).to.throw(TypeError);
680             expect(function () { return smartObj.exec(NaN); }).to.throw(TypeError);
681             expect(function () { return smartObj.exec([]); }).to.throw(TypeError);
682             expect(function () { return smartObj.exec({}); }).to.throw(TypeError);
683             expect(function () { return smartObj.exec(true); }).to.throw(TypeError);
684             expect(function () { return smartObj.exec(new Date()); }).to.throw(TypeError);
685             expect(function () { return smartObj.exec(function () {}); }).to.throw(TypeError);
686         });
688         it('should throw TypeError if iid is not a string or a number', function () {
689             expect(function () { return smartObj.exec(5700); }).to.throw(TypeError);
690             expect(function () { return smartObj.exec(5700, undefined); }).to.throw(TypeError);
691             expect(function () { return smartObj.exec(5700, null); }).to.throw(TypeError);
692             expect(function () { return smartObj.exec(5700, NaN); }).to.throw(TypeError);
693             expect(function () { return smartObj.exec(5700, []); }).to.throw(TypeError);
694             expect(function () { return smartObj.exec(5700, {}); }).to.throw(TypeError);
695             expect(function () { return smartObj.exec(5700, true); }).to.throw(TypeError);
696             expect(function () { return smartObj.exec(5700, new Date()); }).to.throw(TypeError);
697             expect(function () { return smartObj.exec(5700, function () {}); }).to.throw(TypeError);
698         });
700         it('should throw TypeError if rid is not a string or a number', function () {
701             expect(function () { return smartObj.exec(); }).to.throw(TypeError);
702             expect(function () { return smartObj.exec(3303, 2, undefined); }).to.throw(TypeError);
703             expect(function () { return smartObj.exec(3303, 2, null); }).to.throw(TypeError);
704             expect(function () { return smartObj.exec(3303, 2, NaN); }).to.throw(TypeError);
705             expect(function () { return smartObj.exec(3303, 2, []); }).to.throw(TypeError);
706             expect(function () { return smartObj.exec(3303, 2, {}); }).to.throw(TypeError);
707             expect(function () { return smartObj.exec(3303, 2, true); }).to.throw(TypeError);
708             expect(function () { return smartObj.exec(3303, 2, new Date()); }).to.throw(TypeError);
709             expect(function () { return smartObj.exec(3303, 2, function () {}); }).to.throw(TypeError);
711             expect(function () { return smartObj.exec(3303, 2, 5700, 30); }).not.to.throw(TypeError);
712             expect(function () { return smartObj.exec(3303, 2, 'temperature', 30); }).not.to.throw(TypeError);
713         });
714     });
715 });