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