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 test = require("./out/build/Release/napitest") 16var assert = require("assert"); 17 18describe('boolean', function () { 19 it('test fun1', function () { 20 let ret = test.fun1(true); 21 assert.deepStrictEqual(ret, false); 22 }); 23 24 it('test fun2', function () { 25 let ret = test.fun2(true, [true, false]); 26 assert.deepStrictEqual(ret, []); 27 }); 28 29 it('test fun3', function () { 30 let ret = test.fun3([true, false], false); 31 assert.deepStrictEqual(ret, []); 32 }); 33 34 it('test fun4', function () { 35 let ret = test.fun4({ 'isTrue': true, 'isExit': false }); 36 assert.deepStrictEqual(ret, false); 37 }); 38 39 it('test fun5', function () { 40 let ret = test.fun5({ 'isTrue': true, 'isExit': false }, true); 41 assert.deepStrictEqual(ret, false); 42 }); 43 44 function asynFun1(err, ret) { 45 assert.strictEqual(err.code, 0) 46 assert.deepStrictEqual(ret, false) 47 } 48 49 function def1(ret) { 50 assert.deepStrictEqual(ret, false); 51 } 52 53 it('test fun6', function () { 54 test.fun6(15, asynFun1); 55 test.fun6(15).then(def1); 56 }); 57 58 it('test fun6', function () { 59 let promiseObj = test.fun6(15); 60 promiseObj.then(ret => { def1(ret) }); 61 }); 62}); 63 64 65describe('boolean', function () { 66 function asynFun2(err, ret) { 67 assert.deepStrictEqual(err.code, 0) 68 assert.deepStrictEqual(ret, []) 69 } 70 71 function def2(ret) { 72 assert.deepStrictEqual(ret, []); 73 } 74 75 it('test fun7', function () { 76 test.fun7(15, asynFun2); 77 test.fun7(15).then(def2); 78 }); 79 80 it('test fun7', function () { 81 let promiseObj = test.fun7(15); 82 promiseObj.then(ret => { def2(ret) }); 83 }); 84 85 function cb1(ret) { 86 assert.deepStrictEqual(ret, false) 87 } 88 89 it('test fun9', function () { 90 test.fun9(15, cb1); 91 }); 92 93 it('test fun10', function () { 94 let ret = test.fun10( 95 { age: true, height: [false, false], width: [true, true] }); 96 assert.deepStrictEqual(typeof ret, 'object'); 97 assert.strictEqual(ret.age, false) 98 assert.deepStrictEqual(ret.height, []) 99 assert.deepStrictEqual(ret.width, []) 100 }); 101}); 102