|
| 1 | +/** |
| 2 | + * Copyright (c) 2017 The Bacardi Authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import * as bindings from 'bindings'; |
| 18 | + |
| 19 | +const bacardi = bindings('bacardi.node'); |
| 20 | + |
| 21 | +test('Test for enum', async () => { |
| 22 | + let test_interface = new bacardi.TestInterface(); |
| 23 | + |
| 24 | + test_interface.voidMethodTestEnumArg('value1'); |
| 25 | + expect(bacardi.TestInterface.getLastCallInfo()) |
| 26 | + .toBe('VoidMethodTestEnumArg(value1)'); |
| 27 | + |
| 28 | + test_interface.voidMethodTestEnumArg('value2'); |
| 29 | + expect(bacardi.TestInterface.getLastCallInfo()) |
| 30 | + .toBe('VoidMethodTestEnumArg(value2)'); |
| 31 | + |
| 32 | + test_interface.voidMethodTestEnumArg('value3'); |
| 33 | + expect(bacardi.TestInterface.getLastCallInfo()) |
| 34 | + .toBe('VoidMethodTestEnumArg(value3)'); |
| 35 | +}); |
| 36 | + |
| 37 | +test('Passing unexpected enum value should throw error', async () => { |
| 38 | + let test_interface = new bacardi.TestInterface(); |
| 39 | + |
| 40 | + expect(() => { |
| 41 | + test_interface.voidMethodTestEnumArg(1); |
| 42 | + }).toThrowError(); |
| 43 | + |
| 44 | + expect(() => { |
| 45 | + test_interface.voidMethodTestEnumArg(''); |
| 46 | + }).toThrowError(); |
| 47 | + |
| 48 | + expect(() => { |
| 49 | + test_interface.voidMethodTestEnumArg('value'); |
| 50 | + }).toThrowError(); |
| 51 | + |
| 52 | +}); |
0 commit comments