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

Convert unit tests to typescript. #34

Open
wants to merge 4 commits into
base: main
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ indent_style = tab
indent_size = 4
trim_trailing_whitespace = true

[*.md]
[*.{md,yml}]
indent_style = space
27 changes: 27 additions & 0 deletions .github/workflows/check-formats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Check Formatting of Code Base

defaults:
run:
shell: bash

on:
push:
branches-ignore: [main]
pull_request:

jobs:
prettier:
name: Check TypeScript, JavaScript, style, and HTML file formatting with prettier
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: Check formatting with prettier
run: npm run format:check
27 changes: 27 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Lint Code Base

defaults:
run:
shell: bash

on:
push:
branches-ignore: [main]
pull_request:

jobs:
eslint:
name: Lint TypeScript and JavaScript files with eslint and style files with stylelint
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies and Build
run: npm ci --ignore-scripts && npm run build
- name: Lint files with eslint and stylelint
run: npm run lint:check
32 changes: 22 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@
"build:web": "webpack --mode production",
"build": "npm run build:web && npm run build:lib",
"serve": "webpack serve --mode development",
"lint:eslint": "eslint ./src ./test ./public --fix",
"lint:eslint": "eslint ./src ./test --fix",
"lint:eslint:check": "eslint ./src ./test",
"lint:stylelint": "stylelint \"./src/**/*.less\" \"./public/**/*.css\" \"./public/**/*.html\" --fix",
"lint:stylelint:check": "stylelint \"./src/**/*.less\" \"./public/**/*.css\" \"./public/**/*.html\"",
"lint": "npm run lint:eslint && npm run lint:stylelint",
"format": "prettier --write ."
"lint:check": "npm run lint:eslint:check && npm run lint:stylelint:check",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"devDependencies": {
"@awmottaz/prettier-plugin-void-html": "^1.6.1",
"@stylistic/eslint-plugin": "^2.7.2",
"@types/mocha": "^10.0.9",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion public/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<title>MathQuill Demo</title>

<link rel="stylesheet" href="support/home.css">
<link rel="stylesheet" href="home.css">
<link rel="stylesheet" href="mathquill.css">

<style>
Expand Down
File renamed without changes.
53 changes: 0 additions & 53 deletions public/support/assert.js

This file was deleted.

20 changes: 5 additions & 15 deletions public/unit-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,9 @@
<script src="mocha/mocha.js"></script>
<link rel="stylesheet" href="mocha/mocha.css">

<!-- home-grown assertions -->
<script src="support/assert.js"></script>

<!-- configure mocha -->
<script>
window.post_xunit_to = new URLSearchParams(location.search).get('post_xunit_to');
mocha.setup({ ui: 'tdd', reporter: post_xunit_to ? 'xunit' : 'html', bail: false });
</script>

<!-- include the library with the tests inlined -->
<script id="mathquill" src="mathquill.test.js"></script>

<!-- include MathQuill-basic -->
<script id="mathquill" src="mathquill.test.js" defer></script>
<link rel="stylesheet" href="mathquill.css">
<script>
MQ = MathQuill.getInterface();
</script>
</head>

<body>
Expand All @@ -36,6 +22,10 @@ <h1>Unit Tests</h1>
<div id="mock"></div>

<script>
// configure mocha
const post_xunit_to = new URLSearchParams(location.search).get('post_xunit_to');
mocha.setup({ ui: 'tdd', reporter: post_xunit_to ? 'xunit' : 'html', bail: false });

teardown(() => {
const mock = document.getElementById('mock');
while (mock.firstChild) mock.firstChild.remove();
Expand Down
2 changes: 1 addition & 1 deletion public/visual-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<title>MathQuill Visual Test Page</title>

<link rel="stylesheet" href="support/home.css">
<link rel="stylesheet" href="home.css">
<link rel="stylesheet" href="mathquill.css">

<script src="mathquill.js"></script>
Expand Down
7 changes: 4 additions & 3 deletions src/commands/mathElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1436,9 +1436,10 @@ const BracketMixin = <TBase extends Constructor<MathCommand>>(Base: TBase) =>

getSymbol(side?: Direction) {
return (
(SVG_SYMBOLS[this.sides[side || 'right'].ch] as
| { width: string; html: string }
| undefined) || { width: '0', html: '' }
(SVG_SYMBOLS[this.sides[side || 'right'].ch] as { width: string; html: string } | undefined) || {
width: '0',
html: ''
}
);
}

Expand Down
14 changes: 0 additions & 14 deletions src/css/fontBasic.less

This file was deleted.

9 changes: 0 additions & 9 deletions src/css/mainBasic.less

This file was deleted.

Loading