diff --git a/packages/arcs/tests/.eslintrc.yml b/packages/arcs/tests/.eslintrc.yml new file mode 100644 index 0000000000..2f8de9aea2 --- /dev/null +++ b/packages/arcs/tests/.eslintrc.yml @@ -0,0 +1,2 @@ +env: + jest: true diff --git a/packages/arcs/tests/boundingBox.test.ts b/packages/arcs/tests/boundingBox.test.ts new file mode 100644 index 0000000000..821e0f108c --- /dev/null +++ b/packages/arcs/tests/boundingBox.test.ts @@ -0,0 +1,52 @@ +import { computeArcBoundingBox } from '../src/boundingBox' + +const boundingBoxCases = [ + { + args: [0, 0, 100, 0, 360], + expected: { + x: -100, + y: -100, + width: 200, + height: 200, + }, + }, + { + args: [0, 0, 100, 0, 90], + expected: { + x: 0, + y: 0, + width: 100, + height: 100, + }, + }, + { + args: [0, 0, 100, -90, 0], + expected: { + x: 0, + y: -100, + width: 100, + height: 100, + }, + }, + { + args: [0, 0, 100, 90, 180], + expected: { + x: -100, + y: 0, + width: 100, + height: 100, + }, + }, +] + +for (const boundingBoxCase of boundingBoxCases) { + const { args, expected } = boundingBoxCase + + test(`computeArcBoundingBox() for position ${args[0]}, ${args[1]} with radius ${args[2]}, starting at ${args[3]}°, ending at ${args[4]}°`, () => { + const box = computeArcBoundingBox(...args) + + for (const prop in expected) { + expect(box).toHaveProperty(prop, expected[prop]) + } + }) +} diff --git a/packages/core/tests/lib/polar/utils.test.js b/packages/core/tests/lib/polar/utils.test.js index fd20604fdf..654fc97a92 100644 --- a/packages/core/tests/lib/polar/utils.test.js +++ b/packages/core/tests/lib/polar/utils.test.js @@ -1,68 +1,9 @@ -/* - * This file is part of the nivo project. - * - * Copyright 2016-present, Raphaël Benitte. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -import { absoluteAngleDegrees, midAngle, computeArcBoundingBox } from '../../../src/lib/polar/utils' +import { absoluteAngleDegrees, midAngle } from '../../../src/lib/polar/utils' test('midAngle() should compute center of given angles', () => { expect(midAngle({ startAngle: 0, endAngle: 90 })).toBe(45) }) -const boundingBoxCases = [ - { - args: [0, 0, 100, 0, 360], - expected: { - x: -100, - y: -100, - width: 200, - height: 200, - }, - }, - { - args: [0, 0, 100, 0, 90], - expected: { - x: 0, - y: 0, - width: 100, - height: 100, - }, - }, - { - args: [0, 0, 100, -90, 0], - expected: { - x: 0, - y: -100, - width: 100, - height: 100, - }, - }, - { - args: [0, 0, 100, 90, 180], - expected: { - x: -100, - y: 0, - width: 100, - height: 100, - }, - }, -] - -for (let boundingBoxCase of boundingBoxCases) { - const { args, expected } = boundingBoxCase - - test(`computeArcBoundingBox() for position ${args[0]}, ${args[1]} with radius ${args[2]}, starting at ${args[3]}°, ending at ${args[4]}°`, () => { - const box = computeArcBoundingBox(...args) - - for (let prop in expected) { - expect(box).toHaveProperty(prop, expected[prop]) - } - }) -} - const absAngleDegUseCases = [ { input: 0,