Skip to content

Commit

Permalink
add geojson tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kavigupta committed Sep 1, 2024
1 parent e122c17 commit d90788a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
10 changes: 9 additions & 1 deletion react/test/mapper_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

import { TARGET, screencap } from './test_utils';
import { TARGET, download_or_check_string, most_recent_download_path, screencap } from './test_utils';

const fs = require('fs');

function check_geojson(t, path) {
download_or_check_string(t, fs.readFileSync(most_recent_download_path(), 'utf8'), path);
}

fixture('mapping')
.page(TARGET + '/mapper.html?settings=H4sIAAAAAAAAA1WOzQ6CQAyEX8XUeCOGixeO%2BggejSEFy7Kh%2B5PdRSWEd7dLjMHe2plvpjMociqg76d60PYBFVwTJoICOs2JAlQzkMWGSbQOOZIoo22TdjZrafIk0O9UwBODzv4I1e2%2BLAW0jl2oo8RugKitYlrtPObDmbEddgcQIKDxGytrSxjgG2Rwq%2FlAkZJoFk3eL2NDPbF%2BQ27OpBRPUiTIiotnX64j0Iu06uWr8ngSd4OR%2FtNdNJLzAd2YY7skAQAA')
Expand All @@ -10,6 +16,7 @@ fixture('mapping')

test("state-map", async t => {
await screencap(t, "state-map");
await check_geojson(t, "state-map-geojson");
})

fixture('mapping-more-complex')
Expand All @@ -24,4 +31,5 @@ test("mapping-more-complex", async t => {
await t.eval(() => location.reload(true));
await t.wait(5000);
await screencap(t, "mapping-more-complex");
await check_geojson(t, "mapping-more-complex-geojson");
})
5 changes: 5 additions & 0 deletions react/test/string_check_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { IS_TESTING } from "./test_utils";

if (!IS_TESTING) {
throw new Error("String tests are in overwrite mode. Set IS_TESTING to true to run tests.");
}
6 changes: 3 additions & 3 deletions react/test/test_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const TARGET = process.env.URBANSTATS_TEST_TARGET ?? "http://localhost:80
export const SEARCH_FIELD = Selector('input').withAttribute('placeholder', 'Search Urban Stats');
export const getLocation = ClientFunction(() => document.location.href);

const IS_TESTING = true;
export const IS_TESTING = false;

export function comparison_page(locations) {
const params = new URLSearchParams();
Expand Down Expand Up @@ -98,7 +98,7 @@ export async function download_image(t, name) {
await copy_most_recent_file(t, name);
}

function most_recent_file_path() {
export function most_recent_download_path() {
// get the most recent file in the downloads folder
const path = require('path');
const downloadsFolder = require('downloads-folder');
Expand All @@ -111,7 +111,7 @@ function most_recent_file_path() {
async function copy_most_recent_file(t, name) {
// copy the file to the screenshots folder
const screenshotsFolder = path.join(__dirname, '..', 'screenshots');
fs.copyFileSync(most_recent_file_path(), path.join(screenshotsFolder, name + '_' + t.browser.name + '.png'));
fs.copyFileSync(most_recent_download_path(), path.join(screenshotsFolder, name + '_' + t.browser.name + '.png'));
}

export async function download_or_check_string(t, string, name) {
Expand Down
Binary file not shown.
Binary file added tests/reference_strings/state-map-geojson.txt
Binary file not shown.

0 comments on commit d90788a

Please sign in to comment.