diff --git a/bootstrap/command/test b/bootstrap/command/test index 91daaff..3be3535 100755 --- a/bootstrap/command/test +++ b/bootstrap/command/test @@ -28,6 +28,7 @@ function is_already_formatted() { if is_already_formatted; then mocha --napi-modules examples/calculator.js + node --napi-modules $(which jest) else echo "You should run |bacardi format| command first." fi diff --git a/package.json b/package.json index 06a65b6..da3c217 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,35 @@ { "devDependencies": { + "@types/jest": "^21.1.2", "@types/node": "^8.0.24", "bindings": "^1.3.0", + "jest": "^21.2.1", + "mkdirp": "^0.5.1", "mocha": "^3.5.0", "node-addon-api": "^0.6.3", "node-gyp": "^3.6.2", "nunjucks": "^3.0.1", - "mkdirp": "^0.5.1", "snake-case": "^2.1.0", + "ts-jest": "^21.1.0", "typescript": "^2.4.2", "webidl2": "^4.1.0" }, "optionalDependencies": { "windows-build-tools": "^1.3.2" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "jsx", + "ts", + "tsx" + ], + "testMatch": [ + "**/*.test.(ts|tsx)" + ], + "transform": { + "^.+\\.(ts|tsx)$": "/node_modules/ts-jest/preprocessor.js" + } } } diff --git a/test/interface_constructor.test.ts b/test/interface_constructor.test.ts new file mode 100644 index 0000000..d0f5c94 --- /dev/null +++ b/test/interface_constructor.test.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2017 The Bacardi Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as bindings from 'bindings'; + +const bacardi = bindings('bacardi.node'); + +test('Constructor basic', async () => { + let test_interface: bacardi.TestInterface = new bacardi.TestInterface(); + expect(true).toBe(test_interface instanceof bacardi.TestInterface); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..45794dc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "baseUrl": ".", + "experimentalDecorators": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "preserveConstEnums": true, + "sourceMap": true, + "target": "es5" + } +}