split test

This commit is contained in:
Robin Appelman 2020-01-31 00:51:39 +01:00
commit 0d382e1541
5 changed files with 27 additions and 26 deletions

View file

@ -39,10 +39,10 @@ npm test -- --safari
* `webpack.config.js` contains the Webpack configuration. You shouldn't need to change this, unless you have very special needs.
* The `js` folder contains your JavaScript code (`index.ts` is used to hook everything into Webpack, you don't need to change it).
* The `js` folder contains your JavaScript code (`test.ts` is used to hook everything into Webpack, you don't need to change it).
* The `src` folder contains your Rust code.
* The `static` folder contains any files that you want copied as-is into the final build. It contains an `index.html` file which loads the `index.ts` file.
* The `static` folder contains any files that you want copied as-is into the final build. It contains an `index.html` file which loads the `test.ts` file.
* The `tests` folder contains your Rust unit tests.

View file

@ -1,22 +1 @@
import {parseDemo} from "./parser";
window.addEventListener('DOMContentLoaded', () => {
document.getElementById('file').onchange = e => {
let file = (e.target as HTMLInputElement).files[0];
let reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onload = async function () {
let bytes = new Uint8Array(reader.result as ArrayBuffer);
console.time('demo_parse');
let parsed = await parseDemo(bytes);
console.timeEnd('demo_parse');
console.log(parsed.getPlayer(150, 2));
};
reader.onerror = function () {
console.log(reader.error);
};
};
});
export {parseDemo, ParsedDemo, PlayerState, WorldBoundaries, Class, Team} from "./parser";

22
js/test.ts Normal file
View file

@ -0,0 +1,22 @@
import {parseDemo} from "./parser";
window.addEventListener('DOMContentLoaded', () => {
document.getElementById('file').onchange = e => {
let file = (e.target as HTMLInputElement).files[0];
let reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onload = async function () {
let bytes = new Uint8Array(reader.result as ArrayBuffer);
console.time('demo_parse');
let parsed = await parseDemo(bytes);
console.timeEnd('demo_parse');
console.log(parsed.getPlayer(150, 2));
};
reader.onerror = function () {
console.log(reader.error);
};
};
});

View file

@ -5,7 +5,7 @@
<title>My Rust + Webpack project!</title>
</head>
<body>
<script src="index.js"></script>
<script src="test.js"></script>
<input type="file" id="file"/>
</body>
</html>

View file

@ -7,7 +7,7 @@ const dist = path.resolve(__dirname, "dist");
module.exports = {
mode: "production",
entry: {
index: "./js/index.ts"
test: "./js/test.ts"
},
output: {
path: dist,