-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update-hu-capacity
- Loading branch information
Showing
50 changed files
with
1,221 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`handleMultiPolygon > should correctly handle a valid MultiPolygon feature 1`] = ` | ||
[ | ||
{ | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[ | ||
0, | ||
0, | ||
], | ||
[ | ||
0, | ||
1, | ||
], | ||
[ | ||
1, | ||
1, | ||
], | ||
[ | ||
1, | ||
0, | ||
], | ||
[ | ||
0, | ||
0, | ||
], | ||
], | ||
], | ||
"type": "Polygon", | ||
}, | ||
"properties": { | ||
"name": "Test MultiPolygon", | ||
}, | ||
"type": "Feature", | ||
}, | ||
{ | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[ | ||
2, | ||
2, | ||
], | ||
[ | ||
2, | ||
3, | ||
], | ||
[ | ||
3, | ||
3, | ||
], | ||
[ | ||
3, | ||
2, | ||
], | ||
[ | ||
2, | ||
2, | ||
], | ||
], | ||
], | ||
"type": "Polygon", | ||
}, | ||
"properties": { | ||
"name": "Test MultiPolygon", | ||
}, | ||
"type": "Feature", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`handlePolygon > should correctly handle a valid polygon feature 1`] = ` | ||
{ | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[ | ||
0, | ||
0, | ||
], | ||
[ | ||
0, | ||
1, | ||
], | ||
[ | ||
1, | ||
1, | ||
], | ||
[ | ||
1, | ||
0, | ||
], | ||
[ | ||
0, | ||
0, | ||
], | ||
], | ||
], | ||
"type": "Polygon", | ||
}, | ||
"properties": { | ||
"name": "Test Polygon", | ||
}, | ||
"type": "Feature", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Properties } from '@turf/turf'; | ||
import { Feature, MultiPolygon, Polygon } from 'geojson'; | ||
import { describe, expect, it, vi } from 'vitest'; | ||
|
||
import { handleMultiPolygon, handlePolygon, log } from './utilities'; | ||
|
||
describe('log', () => { | ||
it('should log the correct error message with formatting', () => { | ||
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {}); | ||
|
||
const message = 'Test error message'; | ||
log(message); | ||
|
||
expect(consoleErrorSpy).toHaveBeenCalledWith( | ||
'\u001B[31m%s\u001B[0m', | ||
`ERROR: ${message}` | ||
); | ||
|
||
consoleErrorSpy.mockRestore(); | ||
}); | ||
}); | ||
|
||
describe('handlePolygon', () => { | ||
it('should correctly handle a valid polygon feature', () => { | ||
const feature: Feature<Polygon, Properties> = { | ||
type: 'Feature', | ||
geometry: { | ||
type: 'Polygon', | ||
coordinates: [ | ||
[ | ||
[0, 0], | ||
[0, 1], | ||
[1, 1], | ||
[1, 0], | ||
[0, 0], | ||
], | ||
], | ||
}, | ||
properties: { | ||
name: 'Test Polygon', | ||
}, | ||
}; | ||
|
||
const actual = handlePolygon(feature); | ||
|
||
expect(actual).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('handleMultiPolygon', () => { | ||
it('should correctly handle a valid MultiPolygon feature', () => { | ||
const feature: Feature<MultiPolygon, Properties> = { | ||
type: 'Feature', | ||
geometry: { | ||
type: 'MultiPolygon', | ||
coordinates: [ | ||
[ | ||
[ | ||
[0, 0], | ||
[0, 1], | ||
[1, 1], | ||
[1, 0], | ||
[0, 0], | ||
], | ||
], | ||
[ | ||
[ | ||
[2, 2], | ||
[2, 3], | ||
[3, 3], | ||
[3, 2], | ||
[2, 2], | ||
], | ||
], | ||
], | ||
}, | ||
properties: { | ||
name: 'Test MultiPolygon', | ||
}, | ||
}; | ||
|
||
const actual = handleMultiPolygon(feature); | ||
|
||
expect(actual).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { cacheBuster } from './helpers'; | ||
|
||
describe('cacheBuster', () => { | ||
it('should return a valid ISO string', () => { | ||
const result = cacheBuster(); | ||
expect(new Date(result).toISOString()).toBe(result); | ||
}); | ||
|
||
it('should round down the minutes to the nearest multiple of 5', () => { | ||
const mockDate = new Date('2023-01-01T12:07:45.000Z'); | ||
vi.setSystemTime(mockDate); | ||
|
||
const result = cacheBuster(); | ||
const resultDate = new Date(result); | ||
|
||
expect(resultDate.getMinutes()).toBe(5); | ||
expect(resultDate.getSeconds()).toBe(0); | ||
expect(resultDate.getMilliseconds()).toBe(0); | ||
}); | ||
|
||
it('should set seconds and milliseconds to 0', () => { | ||
const mockDate = new Date('2023-01-01T12:07:45.678Z'); | ||
vi.setSystemTime(mockDate); | ||
|
||
const result = cacheBuster(); | ||
const resultDate = new Date(result); | ||
|
||
expect(resultDate.getSeconds()).toBe(0); | ||
expect(resultDate.getMilliseconds()).toBe(0); | ||
}); | ||
}); |
Oops, something went wrong.