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 { fun1, fun2, fun3 } = require("./out/build/Release/napitest") 16const { fun4, fun5, fun6 } = require("./out/build/Release/napitest") 17const test = require("./out/build/Release/napitest") 18var assert = require("assert"); 19 20describe('enum', function () { 21 it('test fun1', function () { 22 let ret = fun1('aaaa', test.GrantStatus.PERMISSION_DENIED); 23 assert.strictEqual(ret, test.GrantStatus.PERMISSION_DEFAULT); 24 }); 25 26 it('test fun2', function () { 27 let ret = fun2(18, test.LaunchReason.START_ABILITY); 28 assert.strictEqual(ret, test.LaunchReason.UNKNOWN); 29 }); 30 31 it('test fun3', function () { 32 let ret = fun3('ggg', test.Action.ACTION_DIAL); 33 assert.strictEqual(ret, ''); 34 }); 35 36 it('test fun4', function () { 37 let ret = fun4(18, test.PlayingState.STATE_PLAYING); 38 assert.strictEqual(ret, 0); 39 }); 40 41 function abc(ret) { 42 assert.deepStrictEqual(ret, test.LaunchReason.UNKNOWN); 43 } 44 45 it('test fun5', function () { 46 fun5('aaa', abc); 47 }); 48 49 function asynFun1(err, ret) { 50 assert.deepStrictEqual(err.code, 0) 51 assert.deepStrictEqual(ret, '') 52 } 53 54 it('test fun6', function () { 55 fun6('hhh', asynFun1); 56 fun6('hhh').then(def1); 57 }); 58 59 function def1(ret) { 60 assert.deepStrictEqual(ret, ''); 61 } 62 63 it('test fun6', function () { 64 let promiseObj = fun6('hhh'); 65 promiseObj.then(ret => { def1(ret) }); 66 }); 67}); 68 69