Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test framework #358

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down Expand Up @@ -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",
Expand Down
37 changes: 20 additions & 17 deletions test/ContentTypes.js → test/ContentTypes.ts
Original file line number Diff line number Diff line change
@@ -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, [])
})

Expand All @@ -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)
})
})
})
32 changes: 0 additions & 32 deletions test/board.jsx

This file was deleted.

36 changes: 0 additions & 36 deletions test/card.jsx

This file was deleted.

9 changes: 2 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -19,4 +14,4 @@
"pretty": true,
"experimentalDecorators": true
}
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down