Skip to content

Commit

Permalink
Add a unit tests for typescript types (release-1.24 only)
Browse files Browse the repository at this point in the history
Master will have a more robust test pipeline
  • Loading branch information
mauriciopoppe committed Feb 9, 2024
1 parent 95866fd commit 5460ebd
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 2 deletions.
117 changes: 117 additions & 0 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"build:site": "cp dist/function-plot.js site/js/function-plot.js",
"start": "webpack-dev-server",
"docs": "typedoc --excludeExternals --externalPattern \"**/node_modules/**\" --out site/docs src/index.ts",
"test": "jest"
"test": "jest",
"test:types": "check-dts test/** src/**"
},
"files": [
"/dist"
Expand Down Expand Up @@ -67,6 +68,7 @@
"@typescript-eslint/parser": "^5.37.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^9.1.2",
"check-dts": "^0.7.2",
"core-js": "^3.25.2",
"dox": "^1.0.0",
"eslint": "^8.23.1",
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export interface FunctionPlotDatum {
* - interval: uses the interval arithmetic sampler to render a disjoint set of rectangles
* - scatter: dotted line
*/
graphType?: 'polyline' | 'interval' | 'scatter'
graphType?: 'polyline' | 'interval' | 'scatter' | 'text'

/**
* The type of function to render
Expand Down
21 changes: 21 additions & 0 deletions test/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// test with `npx check-dts`
import functionPlot from '../src/'

functionPlot({
target: '#playground',
data: [
{
graphType: 'text',
location: [1, 1],
text: 'hello world'
},
{
graphType: 'text',
location: [-1, -1],
text: 'foo bar',
attr: {
'text-anchor': 'end'
}
}
]
})

0 comments on commit 5460ebd

Please sign in to comment.