Skip to content

Commit e32b006

Browse files
committed
added cypress e2e test
1 parent d6cde2f commit e32b006

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

cypress/e2e/local-file.cy.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { MaputnikDriver } from "./maputnik-driver";
2+
3+
describe("local file", () => {
4+
const { when, get } = new MaputnikDriver();
5+
6+
beforeEach(() => {
7+
when.setStyle("");
8+
});
9+
10+
describe("PMTiles", () => {
11+
it("valid file loads without error", () => {
12+
const fileName = "polygon-z0.pmtiles"; // a small polygon located at Null Island
13+
14+
const stub = cy.stub();
15+
cy.on('window:alert', stub);
16+
17+
get
18+
.bySelector("file", "type")
19+
.selectFile(`cypress/fixtures/${fileName}`, { force: true });
20+
when.wait(200);
21+
cy.then(() => {
22+
expect(stub).to.not.have.been.called;
23+
});
24+
});
25+
26+
it("invalid file results in error", () => {
27+
const fileName = "example-style.json";
28+
29+
const stub = cy.stub();
30+
cy.on('window:alert', stub);
31+
32+
get
33+
.bySelector("file", "type")
34+
.selectFile(`cypress/fixtures/${fileName}`, { force: true });
35+
when.wait(200);
36+
cy.then(() => {
37+
expect(stub).to.be.called;
38+
expect(stub.getCall(0).args[0]).to.contain('File type must be one of application/octet-stream, .pmtiles');
39+
});
40+
})
41+
});
42+
});

cypress/fixtures/polygon-z0.pmtiles

468 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)