diff --git a/web/client/components/data/featuregrid/formatters/__tests__/index-test.jsx b/web/client/components/data/featuregrid/formatters/__tests__/index-test.jsx index f65164baf9..5e0a27287e 100644 --- a/web/client/components/data/featuregrid/formatters/__tests__/index-test.jsx +++ b/web/client/components/data/featuregrid/formatters/__tests__/index-test.jsx @@ -5,118 +5,178 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ -import React from 'react'; -import ReactDOM from 'react-dom'; -import expect from 'expect'; +import React from "react"; +import ReactDOM from "react-dom"; +import expect from "expect"; -import NumberFormat from '../../../../I18N/Number'; -import {getFormatter, registerFormatter, unregisterFormatter} from '../index'; +import NumberFormat from "../../../../I18N/Number"; +import { getFormatter, registerFormatter, unregisterFormatter } from "../index"; -describe('Tests for the formatter functions', () => { - it('test getFormatter for booleans', () => { - const formatter = getFormatter({localType: "boolean"}); +describe("Tests for the formatter functions", () => { + it("test getFormatter for booleans", () => { + const formatter = getFormatter({ localType: "boolean" }); expect(typeof formatter).toBe("function"); expect(formatter()).toBe(null); - expect(formatter({value: true}).type).toBe("span"); - expect(formatter({value: true}).props.children).toBe("true"); - expect(formatter({value: false}).props.children).toBe("false"); - expect(formatter({value: null})).toBe(null); - expect(formatter({value: undefined})).toBe(null); + expect(formatter({ value: true }).type).toBe("span"); + expect(formatter({ value: true }).props.children).toBe("true"); + expect(formatter({ value: false }).props.children).toBe("false"); + expect(formatter({ value: null })).toBe(null); + expect(formatter({ value: undefined })).toBe(null); }); - it('test getFormatter for strings', () => { - const value = 'Test https://google.com with google link'; - const formatter = getFormatter({localType: "string"}); + it("test getFormatter for strings", () => { + const value = "Test https://google.com with google link"; + const formatter = getFormatter({ localType: "string" }); expect(typeof formatter).toBe("function"); expect(formatter()).toBe(null); - expect(formatter({value: 'Test no links'})[0]).toBe('Test no links'); - expect(formatter({value})[0]).toBe('Test '); - expect(formatter({value})[1].props.href).toBe('https://google.com'); - expect(formatter({value})[2]).toBe(' with google link'); - expect(formatter({value: null})).toBe(null); - expect(formatter({value: undefined})).toBe(null); + expect(formatter({ value: "Test no links" })[0]).toBe("Test no links"); + expect(formatter({ value })[0]).toBe("Test "); + expect(formatter({ value })[1].props.href).toBe("https://google.com"); + expect(formatter({ value })[2]).toBe(" with google link"); + expect(formatter({ value: null })).toBe(null); + expect(formatter({ value: undefined })).toBe(null); }); - it('test getFormatter for number', () => { - const formatter = getFormatter({localType: "number"}); + it("test getFormatter for number", () => { + const formatter = getFormatter({ localType: "number" }); expect(typeof formatter).toBe("function"); expect(formatter()).toBe(null); - expect(formatter({value: 44.3333434353535}).type).toBe(NumberFormat); - expect(formatter({value: 44.3333434353535}).props.value).toBe(44.3333434353535); - expect(formatter({value: null})).toBe(null); - expect(formatter({value: undefined})).toBe(null); - expect(formatter({value: 0}).props.value).toBe(0); + expect(formatter({ value: 44.3333434353535 }).type).toBe(NumberFormat); + expect(formatter({ value: 44.3333434353535 }).props.value).toBe( + 44.3333434353535 + ); + expect(formatter({ value: null })).toBe(null); + expect(formatter({ value: undefined })).toBe(null); + expect(formatter({ value: 0 }).props.value).toBe(0); }); - it('test getFormatter for int', () => { - const formatter = getFormatter({localType: "int"}); + it("test getFormatter for int", () => { + const formatter = getFormatter({ localType: "int" }); expect(typeof formatter).toBe("function"); expect(formatter()).toBe(null); - expect(formatter({value: 2455567}).type).toBe(NumberFormat); - expect(formatter({value: 2455567}).props.value).toBe(2455567); - expect(formatter({value: null})).toBe(null); - expect(formatter({value: undefined})).toBe(null); - expect(formatter({value: 0}).props.value).toBe(0); + expect(formatter({ value: 2455567 }).type).toBe(NumberFormat); + expect(formatter({ value: 2455567 }).props.value).toBe(2455567); + expect(formatter({ value: null })).toBe(null); + expect(formatter({ value: undefined })).toBe(null); + expect(formatter({ value: 0 }).props.value).toBe(0); }); - it('test getFormatter for geometry', () => { - const formatter = getFormatter({localType: "Geometry"}); + it("test getFormatter for geometry", () => { + const formatter = getFormatter({ localType: "Geometry" }); expect(typeof formatter).toBe("function"); expect(formatter()).toBe(null); - expect(formatter({value: {properties: {}, geometry: {type: "Point", coordinates: [1, 2]}}})).toBe(null); - expect(formatter({value: null})).toBe(null); - expect(formatter({value: undefined})).toBe(null); + expect( + formatter({ + value: { + properties: {}, + geometry: { type: "Point", coordinates: [1, 2] } + } + }) + ).toBe(null); + expect(formatter({ value: null })).toBe(null); + expect(formatter({ value: undefined })).toBe(null); }); - describe('test featureGridFormatter', () => { + describe("test featureGridFormatter", () => { beforeEach((done) => { document.body.innerHTML = '
'; setTimeout(done); }); afterEach((done) => { - ReactDOM.unmountComponentAtNode(document.getElementById("container")); - document.body.innerHTML = ''; + ReactDOM.unmountComponentAtNode( + document.getElementById("container") + ); + document.body.innerHTML = ""; setTimeout(done); }); - it('base', () => { + it("base", () => { try { - registerFormatter("test", ({config, value}) => { + registerFormatter("test", ({ config, value }) => { expect(config).toExist(); expect(value).toBe("test"); return