diff --git a/package.json b/package.json index efa026f1..8764c4e0 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "format": "concurrently yarn:format:*", "format:css": "prettier --write src/**/*.css", "format:js": "eslint --cache --color --ext .jsx,.js,.tsx,.ts src", - "test": "electron-mocha --renderer test/**/*.{js,jsx,ts,tsx}", + "test": "electron-mocha -r ts-node/register --renderer test/**/*.{js,jsx,ts,tsx}", "postinstall": "electron-builder install-app-deps" }, "keywords": [], @@ -78,6 +78,7 @@ "@types/hard-source-webpack-plugin": "^1.0.1", "@types/html-webpack-plugin": "^3.2.0", "@types/mime-types": "^2.1.0", + "@types/mocha": "^5.2.7", "@types/node-ipc": "^9.1.1", "@types/prop-types": "^15.7.1", "@types/quill": "^2.0.2", diff --git a/test/ContentTypes.js b/test/ContentTypes.ts similarity index 60% rename from test/ContentTypes.js rename to test/ContentTypes.ts index c712d2a3..3d2e9f18 100644 --- a/test/ContentTypes.js +++ b/test/ContentTypes.ts @@ -1,30 +1,33 @@ import assert from 'assert' -import ContentTypes from '../src/renderer/ContentTypes' +import * as ContentTypes from '../src/renderer/ContentTypes' -class UrlContent { } +class UrlContent {} describe('ContentTypes', () => { describe('registers a type', () => { ContentTypes.register({ type: 'url', - contexts: { workspace: UrlContent, board: UrlContent }, + contexts: { workspace: UrlContent as any, board: UrlContent as any }, name: 'URL', - icon: 'chain' + icon: 'chain', }) it('finds the registered type', () => { const type = ContentTypes.lookup({ type: 'url', context: 'workspace' }) - assert.equal(type.component, UrlContent) + assert.equal(type && type.component, UrlContent) }) it('lists types for a given context', () => { const types = ContentTypes.list({ context: 'board' }) - assert.deepEqual(types.map(t => t.component), [UrlContent]) + assert.deepEqual( + types.map((t) => t.component), + [UrlContent] + ) }) it('lists no types for unregistered contexts', () => { - const types = ContentTypes.list({ context: 'foo' }) + const types = ContentTypes.list({ context: 'foo' as any }) assert.deepEqual(types, []) }) @@ -34,31 +37,31 @@ describe('ContentTypes', () => { }) it('defaults to a sensible default for a context', () => { - class DefaultListContent { } + class DefaultListContent {} ContentTypes.registerDefault({ - component: DefaultListContent, - context: 'list' + component: DefaultListContent as any, + context: 'list', }) const type = ContentTypes.lookup({ type: 'url', context: 'list' }) - assert.strictEqual(type.component, DefaultListContent) + assert.strictEqual(type && type.component, DefaultListContent) }) it('preserves the type-name and icon when returning a default renderer', () => { const type = ContentTypes.lookup({ type: 'url', context: 'list' }) - assert.strictEqual(type.name, 'URL') - assert.strictEqual(type.icon, 'chain') + assert.strictEqual(type && type.name, 'URL') + assert.strictEqual(type && type.icon, 'chain') }) it('uses a specific option if available for a context', () => { - class ImageInListContent { } + class ImageInListContent {} ContentTypes.register({ type: 'image', - contexts: { list: ImageInListContent }, + contexts: { list: ImageInListContent as any }, name: 'Image', - icon: 'chain' + icon: 'chain', }) const type = ContentTypes.lookup({ type: 'image', context: 'list' }) - assert.strictEqual(type.component, ImageInListContent) + assert.strictEqual(type && type.component, ImageInListContent) }) }) }) diff --git a/test/board.jsx b/test/board.jsx deleted file mode 100644 index bc66a8a3..00000000 --- a/test/board.jsx +++ /dev/null @@ -1,32 +0,0 @@ -import assert from 'assert' -import { configure, mount } from 'enzyme' -import Adapter from 'enzyme-adapter-react-16' -import * as React from 'react' - -import Board from '../src/renderer/components/board/board' - -configure({ adapter: new Adapter() }) - -describe('<Board />', () => { - describe('should be instantiable', () => { - const props = { - cards: [{ - type: 'text', - id: 'imaginary-card-id', - x: 0, - y: 0, - height: 10, - width: 24, - text: '' - }], - backgroundColor: '#fff', - selected: ['imaginary-card-id'] - } - - const wrapper = mount(<Board {...props} />) - - it('should equal itself', () => { - assert.equal(wrapper, wrapper) - }) - }) -}) diff --git a/test/card.jsx b/test/card.jsx deleted file mode 100644 index 9241bfc8..00000000 --- a/test/card.jsx +++ /dev/null @@ -1,36 +0,0 @@ -import assert from 'assert' -import { configure, shallow/* , mount, render */ } from 'enzyme' -import Adapter from 'enzyme-adapter-react-16' -import * as React from 'react' - -import Card from '../src/renderer/components/board/board-card' - -configure({ adapter: new Adapter() }) - -describe('<Card />', () => { - describe('should be instantiable', () => { - const props = { - card: { - type: 'text', - id: 1, - x: 0, - y: 0, - height: 10, - width: 24, - text: '' - }, - dragState: { - moveX: 0, - moveY: 0, - resizeWidth: 48, - resizeHeight: 48 - } - } - - const wrapper = shallow(<Card {...props} />) - - it('should equal itself', () => { - assert.equal(wrapper, wrapper) - }) - }) -}) diff --git a/tsconfig.json b/tsconfig.json index 512c717c..afe842f6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,12 +5,7 @@ "noImplicitAny": false, "sourceMap": true, "noFallthroughCasesInSwitch": true, - "lib": [ - "es2015", - "es2017", - "dom", - "webworker" - ], + "lib": ["es2015", "es2017", "dom", "webworker"], "target": "es2016", "module": "CommonJS", "esModuleInterop": true, @@ -19,4 +14,4 @@ "pretty": true, "experimentalDecorators": true } -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 5a346ef8..d29f37d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -546,6 +546,11 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== +"@types/mocha@^5.2.7": + version "5.2.7" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.7.tgz#315d570ccb56c53452ff8638738df60726d5b6ea" + integrity sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ== + "@types/node-ipc@^9.1.1": version "9.1.1" resolved "https://registry.yarnpkg.com/@types/node-ipc/-/node-ipc-9.1.1.tgz#81eb93874b5c7a8e0bd0ca3265a6661bd2b3a52b"