Skip to content

Commit 93ef0e5

Browse files
authored
Merge pull request #34 from drgrice1/mathspeak-plus-unit-test-work
Convert unit tests to typescript.
2 parents 231727a + 48d013f commit 93ef0e5

38 files changed

+1094
-670
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ indent_style = tab
99
indent_size = 4
1010
trim_trailing_whitespace = true
1111

12-
[*.md]
12+
[*.{md,yml}]
1313
indent_style = space
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Check Formatting of Code Base
3+
4+
defaults:
5+
run:
6+
shell: bash
7+
8+
on:
9+
push:
10+
branches-ignore: [main]
11+
pull_request:
12+
13+
jobs:
14+
prettier:
15+
name: Check TypeScript, JavaScript, style, and HTML file formatting with prettier
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
- name: Install Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
- name: Install Dependencies
25+
run: npm ci --ignore-scripts
26+
- name: Check formatting with prettier
27+
run: npm run format:check

.github/workflows/linter.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Lint Code Base
3+
4+
defaults:
5+
run:
6+
shell: bash
7+
8+
on:
9+
push:
10+
branches-ignore: [main]
11+
pull_request:
12+
13+
jobs:
14+
eslint:
15+
name: Lint TypeScript and JavaScript files with eslint and style files with stylelint
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
- name: Install Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
- name: Install Dependencies and Build
25+
run: npm ci --ignore-scripts && npm run build
26+
- name: Lint files with eslint and stylelint
27+
run: npm run lint:check

package-lock.json

Lines changed: 22 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@
2424
"build:web": "webpack --mode production",
2525
"build": "npm run build:web && npm run build:lib",
2626
"serve": "webpack serve --mode development",
27-
"lint:eslint": "eslint ./src ./test ./public --fix",
27+
"lint:eslint": "eslint ./src ./test --fix",
28+
"lint:eslint:check": "eslint ./src ./test",
2829
"lint:stylelint": "stylelint \"./src/**/*.less\" \"./public/**/*.css\" \"./public/**/*.html\" --fix",
30+
"lint:stylelint:check": "stylelint \"./src/**/*.less\" \"./public/**/*.css\" \"./public/**/*.html\"",
2931
"lint": "npm run lint:eslint && npm run lint:stylelint",
30-
"format": "prettier --write ."
32+
"lint:check": "npm run lint:eslint:check && npm run lint:stylelint:check",
33+
"format": "prettier --write .",
34+
"format:check": "prettier --check ."
3135
},
3236
"devDependencies": {
3337
"@awmottaz/prettier-plugin-void-html": "^1.6.1",
3438
"@stylistic/eslint-plugin": "^2.7.2",
39+
"@types/mocha": "^10.0.9",
3540
"copy-webpack-plugin": "^12.0.2",
3641
"css-loader": "^7.1.2",
3742
"css-minimizer-webpack-plugin": "^7.0.0",

public/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<title>MathQuill Demo</title>
99

10-
<link rel="stylesheet" href="support/home.css">
10+
<link rel="stylesheet" href="home.css">
1111
<link rel="stylesheet" href="mathquill.css">
1212

1313
<style>
File renamed without changes.

public/support/assert.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

public/unit-test.html

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,9 @@
1111
<script src="mocha/mocha.js"></script>
1212
<link rel="stylesheet" href="mocha/mocha.css">
1313

14-
<!-- home-grown assertions -->
15-
<script src="support/assert.js"></script>
16-
17-
<!-- configure mocha -->
18-
<script>
19-
window.post_xunit_to = new URLSearchParams(location.search).get('post_xunit_to');
20-
mocha.setup({ ui: 'tdd', reporter: post_xunit_to ? 'xunit' : 'html', bail: false });
21-
</script>
22-
2314
<!-- include the library with the tests inlined -->
24-
<script id="mathquill" src="mathquill.test.js"></script>
25-
26-
<!-- include MathQuill-basic -->
15+
<script id="mathquill" src="mathquill.test.js" defer></script>
2716
<link rel="stylesheet" href="mathquill.css">
28-
<script>
29-
MQ = MathQuill.getInterface();
30-
</script>
3117
</head>
3218

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

3824
<script>
25+
// configure mocha
26+
const post_xunit_to = new URLSearchParams(location.search).get('post_xunit_to');
27+
mocha.setup({ ui: 'tdd', reporter: post_xunit_to ? 'xunit' : 'html', bail: false });
28+
3929
teardown(() => {
4030
const mock = document.getElementById('mock');
4131
while (mock.firstChild) mock.firstChild.remove();

public/visual-test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<title>MathQuill Visual Test Page</title>
99

10-
<link rel="stylesheet" href="support/home.css">
10+
<link rel="stylesheet" href="home.css">
1111
<link rel="stylesheet" href="mathquill.css">
1212

1313
<script src="mathquill.js"></script>

0 commit comments

Comments
 (0)