Skip to content

Commit

Permalink
Unit tests for cache
Browse files Browse the repository at this point in the history
  • Loading branch information
steinbro committed Nov 25, 2024
1 parent 8297fc8 commit c80cf4f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/state/cache.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { cache } from "./cache";
import { expect } from "chai";

describe("cache", () => {
it('should be empty for unloaded tiles', () => {
cache.getFeatures("16/18109/23965").then((result) => {
expect(result.length).to.equal(0);
});
});

it('should store and retrieve features', () => {
// Real feature extracted from tile
cache.addFeature({
"feature_type": "amenity",
"feature_value": "cafe",
"geometry": {
"coordinates": [-80.52166, 43.463198],
"type": "Point"
},
"osm_ids": [503048818],
"properties": {
"amenity": "cafe",
"cuisine": "bubble_tea",
"name": "The Bingsu"
},
"type": "Feature"
},
"16/18109/23965");

cache.getFeatures("16/18109/23965").then((result) => {
expect(result.length).to.equal(1);
expect(result[0]).to.include({
"feature_type": "amenity",
"feature_value": "cafe",
});
});
});
});

0 comments on commit c80cf4f

Please sign in to comment.