mirror of
https://github.com/rastapasta/mapscii.git
synced 2025-03-26 13:26:09 +01:00
Add more unit tests
This commit is contained in:
parent
3f4bd472cf
commit
7b80ac883a
10
src/BrailleBuffer.spec.js
Normal file
10
src/BrailleBuffer.spec.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import BrailleBuffer from './BrailleBuffer.js';
|
||||||
|
|
||||||
|
const termReset = '\x1B[39;49m';
|
||||||
|
|
||||||
|
describe('BrailleBuffer', () => {
|
||||||
|
test('starts a frame with term reset characters', async () => {
|
||||||
|
const brailleBuffer = new BrailleBuffer(1, 1);
|
||||||
|
expect(brailleBuffer.frame().startsWith(termReset)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
21
src/Renderer.spec.js
Normal file
21
src/Renderer.spec.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import fsPromises from 'fs/promises';
|
||||||
|
import Renderer from './Renderer';
|
||||||
|
import TileSource from './TileSource.js';
|
||||||
|
|
||||||
|
const center = {
|
||||||
|
lat: 52.51298,
|
||||||
|
lon: 13.42012,
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Renderer', () => {
|
||||||
|
describe('with a HTTP source', () => {
|
||||||
|
test('does not crash when creating a Renderer', async () => {
|
||||||
|
const tileSource = new TileSource();
|
||||||
|
await tileSource.init('http://mapscii.me/');
|
||||||
|
const style = JSON.parse(await fsPromises.readFile('./styles/dark.json'));
|
||||||
|
const renderer = new Renderer(tileSource, style);
|
||||||
|
renderer.setSize(30, 30);
|
||||||
|
expect(await renderer.draw(center, 13)).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
12
src/Styler.spec.js
Normal file
12
src/Styler.spec.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import fsPromises from 'fs/promises';
|
||||||
|
import Styler from './Styler';
|
||||||
|
|
||||||
|
describe('Styler', () => {
|
||||||
|
describe('getStyleFor', () => {
|
||||||
|
test('returns false for landuse_park, line', async () => {
|
||||||
|
const style = JSON.parse(await fsPromises.readFile('./styles/dark.json'));
|
||||||
|
const styler = new Styler(style);
|
||||||
|
expect(styler.getStyleFor('landuse_park', 'line')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
BIN
src/__snapshots__/Renderer.spec.js.snap
Normal file
BIN
src/__snapshots__/Renderer.spec.js.snap
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user