Skip to content

Commit

Permalink
Merge pull request #5 from Juliiiian/master
Browse files Browse the repository at this point in the history
Moved and fixed examples
  • Loading branch information
Dezinater authored Nov 19, 2023
2 parents a095015 + d10760e commit 15a74cd
Show file tree
Hide file tree
Showing 16 changed files with 331 additions and 324 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
node_modules
/dist
/public/*.map
/test/test-write.map
/test/examples/test-maps/*


# local env files
Expand Down
7 changes: 2 additions & 5 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extension": [
"js"
],
"spec": "test/**/*.spec.js"
}
"extension": ["js"]
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ fs.readFile(__dirname + '/../../test/test.map', function (err, fileContents) {
The package comes with Typescript definitions so if you are using Typescript you will be able to see every method and class available to use. To get started take a look at the examples for some code samples.
- [generate-circle-plots](https://github.com/Dezinater/RustWorldJS/tree/master/examples/generate-circle-plots)
- [get-map-size](https://github.com/Dezinater/RustWorldJS/tree/master/examples/get-map-size)
- [get-terrainmap-info](https://github.com/Dezinater/RustWorldJS/tree/master/examples/get-terrainmap-info)
- [ice-walls](https://github.com/Dezinater/RustWorldJS/tree/master/examples/ice-walls)
- [get-map-size](https://github.com/Dezinater/RustWorldJS/tree/master/test/examples/get-map-size.js)
- [get-terrainmap-info](https://github.com/Dezinater/RustWorldJS/tree/master/test/examples/get-terrainmap-info.js)
- [generate-circle-plots](https://github.com/Dezinater/RustWorldJS/tree/master/test/examples/generate-circle-plots.js)
- [ice-walls](https://github.com/Dezinater/RustWorldJS/tree/master/test/examples/ice-walls.js)
## LZ4 Compression
Expand Down
79 changes: 0 additions & 79 deletions examples/generate-circle-plots/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions examples/get-map-size/index.js

This file was deleted.

19 changes: 0 additions & 19 deletions examples/get-terrainmap-info/index.js

This file was deleted.

57 changes: 0 additions & 57 deletions examples/ice-walls/index.js

This file was deleted.

56 changes: 29 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
{
"name": "rustworld",
"version": "1.0.3",
"type": "module",
"license": "BSD-2-Clause",
"exports": "./src/index.js",
"main": "./src/index.js",
"files": [
"/src"
],
"scripts": {
"test": "mocha"
},
"directories": {
"lib": "./src",
"test": "./test"
},
"dependencies": {
"protobufjs": "^7.1.1",
"web-worker": "^1.2.0"
},
"devDependencies": {
"mocha": "^10.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Dezinater/RustWorldJS.git"
}
"name": "rustworld",
"version": "1.0.3",
"type": "module",
"license": "BSD-2-Clause",
"exports": "./src/index.js",
"main": "./src/index.js",
"files": [
"/src"
],
"scripts": {
"test": "mocha test/LoadMap.spec.js test/WriteMap.spec.js test/Examples.spec.js",
"test-RandW": "mocha test/LoadMap.spec.js test/WriteMap.spec.js",
"test-Examples": "mocha test/Examples.spec.js"
},
"directories": {
"lib": "./src",
"test": "./test"
},
"dependencies": {
"protobufjs": "^7.1.1",
"web-worker": "^1.2.0"
},
"devDependencies": {
"mocha": "^10.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Dezinater/RustWorldJS.git"
}
}
34 changes: 34 additions & 0 deletions test/Examples.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import assert from 'assert';
import * as fs from 'fs/promises';
import generateCirclePlots from './examples/generate-circle-plots.js';
import generateIceWalls from './examples/ice-walls.js';
import getTerrainInfo from './examples/get-terrainmap-info.js';
import getMapSize from './examples/get-map-size.js';

describe('Examples', function () {
this.timeout(120000);

before(async function () {
try {
await fs.access('./test/examples/test-maps');
} catch (error) {
await fs.mkdir('./test/examples/test-maps');
}
});

it('Get terrain info', async function () {
assert.equal(await getTerrainInfo(), true);
});

it('Get map size', async function () {
assert.equal(await getMapSize(), true);
});

it('Generating circle plots', async function () {
assert.equal(await generateCirclePlots(), true);
});

it('Generating ice walls', async function () {
assert.equal(await generateIceWalls(), true);
});
});
Loading

0 comments on commit 15a74cd

Please sign in to comment.