Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
panaaj committed Sep 28, 2024
1 parent dfe4cd4 commit dd3123b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions test/expected-charts.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"minzoom": 3,
"name": "MBTILES_19",
"scale": 250000,
"tilemapUrl": "/signalk/v1/api/resources/charts/test/{z}/{x}/{y}",
"tilemapUrl": "http://localhost:3000/chart-tiles/test/{z}/{x}/{y}",
"type": "tilelayer"
},
"tms-tiles": {
Expand All @@ -32,7 +32,7 @@
"minzoom": 4,
"name": "Översikt Svenska Sjökort",
"scale": 4000000,
"tilemapUrl": "/signalk/v1/api/resources/charts/tms-tiles/{z}/{x}/{y}",
"tilemapUrl": "http://localhost:3000/chart-tiles/tms-tiles/{z}/{x}/{y}",
"type": "tilelayer"
},
"unpacked-tiles": {
Expand All @@ -50,7 +50,7 @@
"minzoom": 3,
"name": "NOAA MBTiles test file",
"scale": 250000,
"tilemapUrl": "/signalk/v1/api/resources/charts/unpacked-tiles/{z}/{x}/{y}",
"tilemapUrl": "http://localhost:3000/chart-tiles/unpacked-tiles/{z}/{x}/{y}",
"type": "tilelayer"
}
}
13 changes: 7 additions & 6 deletions test/plugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ describe('GET /resources/charts', () => {

})

describe('GET /resources/charts/:identifier/:z/:x/:y', () => {

describe('GET /chart-tiles/:identifier/:z/:x/:y', () => {
let plugin
let testServer
beforeEach(() =>
Expand All @@ -123,7 +124,7 @@ describe('GET /resources/charts/:identifier/:z/:x/:y', () => {

it('returns correct tile from MBTiles file', () => {
return plugin.start({})
.then(() => get(testServer, '/signalk/v1/api/resources/charts/test/4/5/6'))
.then(() => get(testServer, '/chart-tiles/test/4/5/6'))
.then(response => {
// unpacked-tiles contains same tiles as the test.mbtiles file
expectTileResponse(response, 'charts/unpacked-tiles/4/5/6.png', 'image/png')
Expand All @@ -133,7 +134,7 @@ describe('GET /resources/charts/:identifier/:z/:x/:y', () => {
it('returns correct tile from directory', () => {
const expectedTile = fs.readFileSync(path.resolve(__dirname, 'charts/unpacked-tiles/4/4/6.png'))
return plugin.start({})
.then(() => get(testServer, '/signalk/v1/api/resources/charts/unpacked-tiles/4/4/6'))
.then(() => get(testServer, '/chart-tiles/unpacked-tiles/4/4/6'))
.then(response => {
expectTileResponse(response, 'charts/unpacked-tiles/4/4/6.png', 'image/png')
})
Expand All @@ -143,15 +144,15 @@ describe('GET /resources/charts/:identifier/:z/:x/:y', () => {
const expectedTile = fs.readFileSync(path.resolve(__dirname, 'charts/tms-tiles/5/17/21.png'))
// Y-coordinate flipped
return plugin.start({})
.then(() => get(testServer, '/signalk/v1/api/resources/charts/tms-tiles/5/17/10'))
.then(() => get(testServer, '/chart-tiles/tms-tiles/5/17/10'))
.then(response => {
expectTileResponse(response, 'charts/tms-tiles/5/17/21.png', 'image/png')
})
})

it('returns 404 for missing tile', () => {
return plugin.start({})
.then(() => get(testServer, '/signalk/v1/api/resources/charts/tms-tiles/5/55/10'))
.then(() => get(testServer, '/chart-tiles/tms-tiles/5/55/10'))
.catch(e => e.response)
.then(response => {
expect(response.status).to.equal(404)
Expand All @@ -160,7 +161,7 @@ describe('GET /resources/charts/:identifier/:z/:x/:y', () => {

it('returns 404 for wrong chart identifier', () => {
return plugin.start({})
.then(() => get(testServer, '/signalk/v1/api/resources/charts/foo/4/4/6'))
.then(() => get(testServer, '/chart-tiles/foo/4/4/6'))
.catch(e => e.response)
.then(response => {
expect(response.status).to.equal(404)
Expand Down

0 comments on commit dd3123b

Please sign in to comment.