diff --git a/__test__/Geometry/__snapshots__/simplify.test.ts.snap b/__test__/Geometry/__snapshots__/simplify.test.ts.snap new file mode 100644 index 000000000..d56da69d2 --- /dev/null +++ b/__test__/Geometry/__snapshots__/simplify.test.ts.snap @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`路径简化 1`] = ` +Array [ + Vector2 { + "x": 0, + "y": 0, + }, + Vector2 { + "x": 10, + "y": 0, + }, + Vector2 { + "x": 18, + "y": 6, + }, + Vector2 { + "x": 28.3, + "y": 6, + }, +] +`; diff --git a/__test__/Geometry/boxExt.test.ts b/__test__/Geometry/boxExt.test.ts index 84ae4bab5..ee3c802ef 100644 --- a/__test__/Geometry/boxExt.test.ts +++ b/__test__/Geometry/boxExt.test.ts @@ -9,6 +9,5 @@ test('盒子相减', () => let b2 = new Box3Ext(new Vector3(200, 0, 0), new Vector3(205, 10, 300)); let bs = b.substract(b2, 0); - - expect(bs.length).toBe(0); + expect(bs.length).toBe(1); }); diff --git a/package.json b/package.json index afefec750..38aa67de2 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ }, "jest": { "transform": { - ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js" + ".(ts|tsx)": "ts-jest" }, "testRegex": "(/__test__/.*|\\.(test|spec))\\.(ts|tsx|js)$", "moduleFileExtensions": [ diff --git a/src/Common/FileSystem.ts b/src/Common/FileSystem.ts index d447f6f9f..7ad98c3ff 100644 --- a/src/Common/FileSystem.ts +++ b/src/Common/FileSystem.ts @@ -1,5 +1,6 @@ import { ArraybufferUtils } from "./binary/ArraybufferUtils"; import { Base64Utils } from './binary/Base64Utils'; +import { BufferUtils } from "./binary/BufferUtils"; /** * FileSystem is used to read and write files using nunuStudio. diff --git a/src/Common/binary/ArraybufferUtils.js b/src/Common/binary/ArraybufferUtils.ts similarity index 99% rename from src/Common/binary/ArraybufferUtils.js rename to src/Common/binary/ArraybufferUtils.ts index 9622372b2..e48822861 100644 --- a/src/Common/binary/ArraybufferUtils.js +++ b/src/Common/binary/ArraybufferUtils.ts @@ -1,6 +1,3 @@ -"use strict"; - - /** * ArraybufferUtils contains methods to convert from and to ArrayBuffer binary format * diff --git a/src/Common/binary/BufferUtils.js b/src/Common/binary/BufferUtils.js deleted file mode 100644 index 6d2b814b7..000000000 --- a/src/Common/binary/BufferUtils.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; - -/** - * BufferUtils contains methods to convert from and to Node.js Buffer binary format - * - * @class BufferUtils - * @module BinaryUtils - * @static - */ -function BufferUtils(){} - -/** - * Create nodejs buffer from arraybuffer - * - * @method fromArrayBuffer - * @param {Arraybuffer} array - * @return {Buffer} buffer - */ -BufferUtils.fromArrayBuffer = function(array) -{ - var buffer = new Buffer(array.byteLength); - var view = new Uint8Array(array); - - for(var i = 0; i < buffer.length; i++) - { - buffer[i] = view[i]; - } - - return buffer; -}; diff --git a/src/Common/binary/BufferUtils.ts b/src/Common/binary/BufferUtils.ts new file mode 100644 index 000000000..86c122104 --- /dev/null +++ b/src/Common/binary/BufferUtils.ts @@ -0,0 +1,30 @@ +/** + * BufferUtils contains methods to convert from and to Node.js Buffer binary format + * + * @class BufferUtils + * @module BinaryUtils + * @static + */ +export class BufferUtils +{ + /** + * Create nodejs buffer from arraybuffer + * + * @method fromArrayBuffer + * @param {Arraybuffer} array + * @return {Buffer} buffer + */ + static fromArrayBuffer = array => + { + const buffer = new Buffer(array.byteLength); + const view = new Uint8Array(array); + + for (let i = 0; i < buffer.length; i++) + { + buffer[i] = view[i]; + } + + return buffer; + }; + +} diff --git a/tsconfig.json b/tsconfig.json index 92e3dcf59..9fbcb73ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,6 @@ "compilerOptions": { "sourceMap": true, "module": "commonjs", - "allowJs": true, "target": "esnext", "noLib": false, "moduleResolution": "node", @@ -14,13 +13,13 @@ "types": [ "node", "webpack-env", - "webpack-dev-server" + "webpack-dev-server", + "jest" ], "jsx": "react", "experimentalDecorators": true }, "include": [ "./src/**/*", - "./config/**/*", ] }