Last eslint tweak (#18198)

* Should be there now

* Format
This commit is contained in:
Rijk van Zanten
2023-04-14 17:40:50 -04:00
committed by GitHub
parent 37658802b7
commit c48309ab68
293 changed files with 1627 additions and 1 deletions

View File

@@ -8,8 +8,10 @@ describe('utils/flatten-field-groups', () => {
{ name: 'ID', field: 'id', collection: 'test', key: 'id', path: 'id', type: 'integer' },
{ name: 'Test Field', field: 'test', collection: 'test', key: 'test', path: 'test', type: 'string' },
];
expect(flattenFieldGroups(TreeWithoutGroups)).toEqual(TreeWithoutGroups);
});
it('Returns a tree without groups', () => {
const TreeWithGroups: FieldNode[] = [
{ name: 'ID', field: 'id', collection: 'test', key: 'id', path: 'id', type: 'integer' },
@@ -33,6 +35,7 @@ describe('utils/flatten-field-groups', () => {
],
},
];
const TreeWithoutGroups: FieldNode[] = [
{ name: 'ID', field: 'id', collection: 'test', key: 'id', path: 'id', type: 'integer' },
{
@@ -44,8 +47,10 @@ describe('utils/flatten-field-groups', () => {
type: 'string',
},
];
expect(flattenFieldGroups(TreeWithGroups)).toEqual(TreeWithoutGroups);
});
it('Returns a tree without deeply nested groups', () => {
const TreeWithNestedGroups: FieldNode[] = [
{ name: 'ID', field: 'id', collection: 'test', key: 'id', path: 'id', type: 'integer' },
@@ -99,6 +104,7 @@ describe('utils/flatten-field-groups', () => {
],
},
];
const TreeWithoutGroups: FieldNode[] = [
{ name: 'ID', field: 'id', collection: 'test', key: 'id', path: 'id', type: 'integer' },
{
@@ -118,6 +124,7 @@ describe('utils/flatten-field-groups', () => {
type: 'string',
},
];
expect(flattenFieldGroups(TreeWithNestedGroups)).toEqual(TreeWithoutGroups);
});
});

View File

@@ -40,6 +40,7 @@ export function getStyleFromBasemapSource(basemap: BasemapSource): Style | strin
const style: Style = { ...baseStyle };
const source: RasterSource = { type: 'raster' };
if (basemap.attribution) source.attribution = basemap.attribution;
if (basemap.type == 'raster') {
source.tiles = expandUrl(basemap.url);
source.tileSize = basemap.tileSize || 512;
@@ -73,6 +74,7 @@ function expandUrl(url: string): string[] {
}
match = /\{(\d+)-(\d+)\}/.exec(url);
if (match) {
// number range
const stop = parseInt(match[2], 10);
@@ -85,6 +87,7 @@ function expandUrl(url: string): string[] {
}
match = /\{(([a-z0-9]+)(,([a-z0-9]+))+)\}/.exec(url);
if (match) {
// csv
const subdomains = match[1].split(',');

View File

@@ -70,9 +70,11 @@ export class BoxSelectControl {
this.boxElement.className = options?.boxElementClass ?? 'selection-box';
this.groupElement = document.createElement('div');
this.groupElement.className = options?.groupElementClass ?? 'mapboxgl-ctrl mapboxgl-ctrl-group';
this.selectButton = new ButtonControl(options?.selectButtonClass ?? 'ctrl-select', () => {
this.activate(!this.shiftPressed);
});
this.groupElement.appendChild(this.selectButton.element);
this.onKeyDownHandler = this.onKeyDown.bind(this);
@@ -154,10 +156,12 @@ export class BoxSelectControl {
onMouseMove(event: MouseEvent): void {
this.lastPos = this.getMousePosition(event);
const minX = Math.min(this.startPos!.x, this.lastPos!.x),
maxX = Math.max(this.startPos!.x, this.lastPos!.x),
minY = Math.min(this.startPos!.y, this.lastPos!.y),
maxY = Math.max(this.startPos!.y, this.lastPos!.y);
const transform = `translate(${minX}px, ${minY}px)`;
const width = maxX - minX + 'px';
const height = maxY - minY + 'px';
@@ -166,6 +170,7 @@ export class BoxSelectControl {
onMouseUp(event: MouseEvent): void {
this.reset();
if (!this.active()) {
return;
}
@@ -173,6 +178,7 @@ export class BoxSelectControl {
const features = this.map!.queryRenderedFeatures([this.startPos!, this.lastPos!], {
layers: this.layers,
});
this.map!.fire('select.end', { features, alt: event.altKey });
}

View File

@@ -25,9 +25,11 @@ export function expandBBox(bbox: BBox, coord: Coordinate): BBox {
export function getBBox(object: AnyGeometry): BBox {
let bbox: BBox = [Infinity, Infinity, -Infinity, -Infinity];
coordEach(object as AllGeoJSON, (coord) => {
bbox = expandBBox(bbox, coord as Coordinate);
});
return bbox;
}
@@ -118,6 +120,7 @@ export function toGeoJSON(entries: any[], options: GeometryOptions): FeatureColl
export function flatten(geometry?: AnyGeometry): SimpleGeometry[] {
if (!geometry) return [];
if (geometry.type == 'GeometryCollection') {
return geometry.geometries.flatMap(flatten);
}

View File

@@ -31,6 +31,7 @@ test('Ignores PK default value', () => {
name: 'ID',
},
]);
expect(values.value).toStrictEqual({});
});
@@ -45,6 +46,7 @@ test('Ignores schemaless fields', () => {
name: 'Test',
},
]);
expect(values.value).toStrictEqual({});
});
@@ -132,6 +134,7 @@ test('Parses default values', () => {
name: 'Test2',
},
]);
expect(values.value).toStrictEqual({
condition: 'test1',
test1: '---',

View File

@@ -27,6 +27,7 @@ test('Returns NULL for non-existing relations', () => {
test('Returns GROUP for Alias', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'test_collection',
field: 'test_fields',
@@ -47,6 +48,7 @@ test('Returns GROUP for Alias', () => {
test('Returns PRESENTATION for Alias', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'test_collection',
field: 'test_fields',
@@ -68,6 +70,7 @@ test('Returns PRESENTATION for Alias', () => {
test('Returns STANDARD with no relations', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'test_collection',
field: 'test_fields',
@@ -89,6 +92,7 @@ test('Returns STANDARD with no relations', () => {
test('Returns FILE for m2o relations to directus_files', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'test_collection',
field: 'test_fields',
@@ -102,6 +106,7 @@ test('Returns FILE for m2o relations to directus_files', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{
collection: 'test_collection',
@@ -126,6 +131,7 @@ test('Returns FILE for m2o relations to directus_files', () => {
test('Returns M2O', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'test_collection',
field: 'test_fields',
@@ -139,6 +145,7 @@ test('Returns M2O', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{
collection: 'test_collection',
@@ -163,6 +170,7 @@ test('Returns M2O', () => {
test('Returns O2M', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'test_collection',
field: 'test_fields',
@@ -176,6 +184,7 @@ test('Returns O2M', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{
collection: 'test_collection',
@@ -200,6 +209,7 @@ test('Returns O2M', () => {
test('Returns TRANSLATIONS for special M2M relations', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'test_collection',
field: 'translations',
@@ -215,6 +225,7 @@ test('Returns TRANSLATIONS for special M2M relations', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{
collection: 'test_collection_translations',
@@ -256,6 +267,7 @@ test('Returns TRANSLATIONS for special M2M relations', () => {
test('Returns M2A', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'collection_a',
field: 'm2a',
@@ -272,6 +284,7 @@ test('Returns M2A', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{
collection: 'test_collection_m2a',
@@ -313,6 +326,7 @@ test('Returns M2A', () => {
test('Returns M2O for searched relation', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'collection_a',
field: 'relation',
@@ -328,6 +342,7 @@ test('Returns M2O for searched relation', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{
collection: 'collection_a_collection_b',
@@ -368,6 +383,7 @@ test('Returns M2O for searched relation', () => {
test('Returns FILES for M2M relations to directus_files', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'collection_a',
field: 'relation',
@@ -383,6 +399,7 @@ test('Returns FILES for M2M relations to directus_files', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{
collection: 'collection_a_directus_files',
@@ -423,6 +440,7 @@ test('Returns FILES for M2M relations to directus_files', () => {
test('Returns M2M ', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'collection_a',
field: 'relation',
@@ -438,6 +456,7 @@ test('Returns M2M ', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{
collection: 'collection_a_collection_b',
@@ -478,6 +497,7 @@ test('Returns M2M ', () => {
test('Returns STANDARD as final fallback', () => {
const fieldsStore = useFieldsStore();
(fieldsStore.getField as Mock).mockReturnValue({
collection: 'test_collection',
field: 'test',
@@ -493,6 +513,7 @@ test('Returns STANDARD as final fallback', () => {
});
const relationsStore = useRelationsStore();
(relationsStore.getRelationsForField as Mock).mockReturnValue([
{ doesnt: 'matter' },
{ doesnt: 'matter' },

View File

@@ -5,6 +5,7 @@ import { jwtPayload } from '@/utils/jwt-payload';
test('Returns payload as JSON object from JWT', () => {
const token =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
const payload = jwtPayload(token);
expect(payload).toEqual({