Skip to content

Commit

Permalink
Merge pull request scpwiki#42 from scpwiki/javascript-test
Browse files Browse the repository at this point in the history
[Web] Javascript testing
  • Loading branch information
rossjrw authored Nov 12, 2020
2 parents 197ce82 + 9116475 commit c5465ce
Show file tree
Hide file tree
Showing 11 changed files with 6,512 additions and 1,493 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: JS tests
on:
# Run this on push to master
push:
branches:
- master
# Run this on push to PRs, regardless of branch
pull_request:
# [Monorepo] Only run this if there are changes to web
# paths:
# - "web/**"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install
run: npm install
- name: Test
run: npm run test
7,949 changes: 6,459 additions & 1,490 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,39 @@
},
"scripts": {
"build": "webpack --config webpack.config.js --mode development",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/scpwiki/wikijump.git"
},
"browserslist": "cover 99.5%",
"babel": {
"presets": [
[ "@babel/preset-env", { "targets": {"node": "current"} } ],
"@babel/preset-typescript"
]
},
"jest": {
"moduleFileExtensions": ["js", "ts"],
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/web/files--common/$1"
}
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@types/jest": "^26.0.15",
"@types/lodash": "^4.14.162",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"babel-jest": "^26.6.3",
"clean-webpack-plugin": "^3.0.0",
"compress-tag": "^2.0.0",
"csstype": "^3.0.4",
"eslint": "^7.13.0",
"jest": "^26.6.3",
"lodash": "^4.17.20",
"query-string": "^6.13.6",
"standardx": "^5.0.0",
Expand Down
8 changes: 8 additions & 0 deletions tests/js/OZONE/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import OZONE from "@/javascript/OZONE";

describe("arrayToPostData", () => {
it("converts an object to a query string", () => {
const obj = { one: "two", three: "four" };
expect(OZONE.utils.arrayToPostData(obj)).toEqual("one=two&three=four");
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"esModuleInterop": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"types": [],
"types": [
"jest"
],
"lib": [
"esnext",
"dom",
Expand All @@ -21,7 +23,8 @@
}
},
"include": [
"web/files--common/**/*.ts"
"web/files--common/**/*.ts",
"tests/js/**/*.ts"
],
"exclude": [
"node_modules"
Expand Down

0 comments on commit c5465ce

Please sign in to comment.