From b2532c019b710b91800d494d57ee970d4fd2581d Mon Sep 17 00:00:00 2001 From: Peter van Hardenberg Date: Tue, 26 Nov 2019 09:53:42 -0800 Subject: [PATCH 1/3] remove long-broken tests --- test/board.jsx | 32 -------------------------------- test/card.jsx | 36 ------------------------------------ 2 files changed, 68 deletions(-) delete mode 100644 test/board.jsx delete mode 100644 test/card.jsx 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('', () => { - 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() - - 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('', () => { - 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() - - it('should equal itself', () => { - assert.equal(wrapper, wrapper) - }) - }) -}) From e13298855f60fa6597e3e7e591460f5db2ac8eda Mon Sep 17 00:00:00 2001 From: Peter van Hardenberg Date: Tue, 26 Nov 2019 10:09:27 -0800 Subject: [PATCH 2/3] fixing the test framework --- package.json | 3 ++- test/ContentTypes.js | 64 -------------------------------------------- tsconfig.json | 9 ++----- yarn.lock | 5 ++++ 4 files changed, 9 insertions(+), 72 deletions(-) delete mode 100644 test/ContentTypes.js 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.js deleted file mode 100644 index c712d2a3..00000000 --- a/test/ContentTypes.js +++ /dev/null @@ -1,64 +0,0 @@ -import assert from 'assert' - -import ContentTypes from '../src/renderer/ContentTypes' - -class UrlContent { } - -describe('ContentTypes', () => { - describe('registers a type', () => { - ContentTypes.register({ - type: 'url', - contexts: { workspace: UrlContent, board: UrlContent }, - name: 'URL', - icon: 'chain' - }) - - it('finds the registered type', () => { - const type = ContentTypes.lookup({ type: 'url', context: 'workspace' }) - assert.equal(type.component, UrlContent) - }) - - it('lists types for a given context', () => { - const types = ContentTypes.list({ context: 'board' }) - assert.deepEqual(types.map(t => t.component), [UrlContent]) - }) - - it('lists no types for unregistered contexts', () => { - const types = ContentTypes.list({ context: 'foo' }) - assert.deepEqual(types, []) - }) - - it('does not find the registered type for other contexts', () => { - const type = ContentTypes.lookup({ type: 'url', context: 'list' }) - assert.strictEqual(type, null) - }) - - it('defaults to a sensible default for a context', () => { - class DefaultListContent { } - ContentTypes.registerDefault({ - component: DefaultListContent, - context: 'list' - }) - const type = ContentTypes.lookup({ type: 'url', context: 'list' }) - assert.strictEqual(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') - }) - - it('uses a specific option if available for a context', () => { - class ImageInListContent { } - ContentTypes.register({ - type: 'image', - contexts: { list: ImageInListContent }, - name: 'Image', - icon: 'chain' - }) - const type = ContentTypes.lookup({ type: 'image', context: 'list' }) - assert.strictEqual(type.component, ImageInListContent) - }) - }) -}) 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" From d1b4e42816e60d226adc1dbfa220e05d9dff242d Mon Sep 17 00:00:00 2001 From: Peter van Hardenberg Date: Tue, 26 Nov 2019 10:12:14 -0800 Subject: [PATCH 3/3] whoops, meant for that to be a rename, not a delete --- test/ContentTypes.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 test/ContentTypes.ts diff --git a/test/ContentTypes.ts b/test/ContentTypes.ts new file mode 100644 index 00000000..3d2e9f18 --- /dev/null +++ b/test/ContentTypes.ts @@ -0,0 +1,67 @@ +import assert from 'assert' + +import * as ContentTypes from '../src/renderer/ContentTypes' + +class UrlContent {} + +describe('ContentTypes', () => { + describe('registers a type', () => { + ContentTypes.register({ + type: 'url', + contexts: { workspace: UrlContent as any, board: UrlContent as any }, + name: 'URL', + icon: 'chain', + }) + + it('finds the registered type', () => { + const type = ContentTypes.lookup({ type: 'url', context: 'workspace' }) + 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] + ) + }) + + it('lists no types for unregistered contexts', () => { + const types = ContentTypes.list({ context: 'foo' as any }) + assert.deepEqual(types, []) + }) + + it('does not find the registered type for other contexts', () => { + const type = ContentTypes.lookup({ type: 'url', context: 'list' }) + assert.strictEqual(type, null) + }) + + it('defaults to a sensible default for a context', () => { + class DefaultListContent {} + ContentTypes.registerDefault({ + component: DefaultListContent as any, + context: 'list', + }) + const type = ContentTypes.lookup({ type: 'url', context: 'list' }) + 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 && type.name, 'URL') + assert.strictEqual(type && type.icon, 'chain') + }) + + it('uses a specific option if available for a context', () => { + class ImageInListContent {} + ContentTypes.register({ + type: 'image', + contexts: { list: ImageInListContent as any }, + name: 'Image', + icon: 'chain', + }) + const type = ContentTypes.lookup({ type: 'image', context: 'list' }) + assert.strictEqual(type && type.component, ImageInListContent) + }) + }) +})