1/* 2* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15const { TestClass1, fun5} = require("./out/build/Release/napitest") 16const { fun6, fun7, fun8} = require("./out/build/Release/napitest") 17const test = require("./out/build/Release/napitest") 18var assert = require("assert"); 19 20describe('Object', function () { 21 var Radio = { 22 RADIO_UNKNOWN : 0, 23 RADIO_GSM : 1, 24 RADIO_1XRTT : 2, 25 } 26 27 let tc1 = new TestClass1(); 28 it('test TestClass1 fun1', function () { 29 let ret = tc1.fun1({"age":10,"name":"nameValue"}); 30 assert.strictEqual(ret, 0); 31 ret = tc1.fun1({"age":[10,15],"name":"nameValue"}); 32 assert.strictEqual(ret,0) 33 ret = tc1.fun1({"age":10,"name":{'test':'"nameValue"'}}); 34 assert.strictEqual(ret,0) 35 ret = tc1.fun1({"age":10,"name":{'test':'nameValue','test1':15}}); 36 assert.strictEqual(ret,0) 37 ret = tc1.fun1({"age":10,"name": Radio.RADIO_GSM}); 38 assert.strictEqual(ret,0) 39 }); 40 41 it('test TestClass1 fun2', function () { 42 let ret = tc1.fun2(2, {"age":10,"name":"nameValue"}); 43 assert.strictEqual(ret, 0); 44 }); 45 46 it('test TestClass1 fun3', function () { 47 let ret = tc1.fun3(2, {"age":10,"name":"nameValue"}, "test4"); 48 assert.strictEqual(ret, 0); 49 }); 50 51 it('test TestClass1 fun4', function () { 52 let ret = tc1.fun4(2); 53 assert.deepStrictEqual(typeof ret, 'object'); 54 }); 55 56 it('test TestClass1 fun9', function () { 57 let ret = tc1.fun9(); 58 assert.strictEqual(ret, 0); 59 }); 60 61}); 62 63describe('Object', function () { 64 var Radio = { 65 RADIO_UNKNOWN : 0, 66 RADIO_GSM : 1, 67 RADIO_1XRTT : 2, 68 } 69 70 it('test fun5', function () { 71 let ret = fun5({"name":"sam","age":10}); 72 assert.strictEqual(ret, 0); 73 ret = fun5({"name":['Sam','Peter'],"age":10}); 74 assert.strictEqual(ret, 0); 75 ret = fun5({"name":{'test': '11'},"age":10}); 76 assert.strictEqual(ret, 0); 77 ret = fun5({"name":{'test': '11','test1':true},"age":10}); 78 assert.strictEqual(ret, 0); 79 ret = fun5({"name":Radio.RADIO_GSM,"age":10}); 80 assert.strictEqual(ret, 0); 81 }); 82 83 it('test fun6', function () { 84 let ret = fun6(2, {"age":10,"name":"nameValue"}); 85 assert.strictEqual(ret, 0); 86 }); 87 88 it('test fun7', function () { 89 let ret = fun7(2, {"age":10,"name":"nameValue"}, "test4"); 90 assert.strictEqual(ret, 0); 91 }); 92 93 it('test fun8', function () { 94 let ret = fun8(2); 95 assert.deepStrictEqual(typeof ret, 'object'); 96 }); 97});