Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure directories + set up tests #18

Merged
merged 11 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
version: 2.1
orbs:
cypress: cypress-io/cypress@1.8.0
jobs:
build:
unit_test:
docker:
# specify the version you desire here
- image: circleci/node:10.16
Expand All @@ -29,4 +31,12 @@ jobs:
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: yarn test
- run: yarn run test:unit
workflows:
unit_and_integration:
jobs:
- unit_test
- cypress/run:
yarn: true
command: yarn run test:integration

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
node_modules
!/src/node_modules
package-lock.json
public/bundle.*
public/bundle.*
test/sandbox/public/bundle.*
5 changes: 5 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"baseUrl": "http://localhost:3009",
"integrationFolder": "test/integration/tests",
"video": false
}
21 changes: 16 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "florence",
"version": "0.0.1",
"svelte": "src/index.js",
"module": "src/index.js",
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@turf/meta": "^6.0.2",
"babel-jest": "^24.8.0",
"cypress": "^3.4.0",
"d3-array": "^2.2.0",
"d3-geo": "^1.11.3",
"d3-interpolate": "^1.3.2",
Expand All @@ -32,18 +35,26 @@
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^4.0.4",
"sirv-cli": "^0.4.0",
"svelte": "^3.4.4"
"svelte": "^3.6.5",
"svero": "^0.5.0"
},
"scripts": {
"build": "rollup -c",
"autobuild": "rollup -c -w",
"autobuild": "rollup -c test/sandbox/rollup.config.js -w",
"autobuild:test": "rollup -c test/integration/testing-app/rollup.config.js -w",
"dev": "run-p start:dev autobuild",
"start": "sirv public",
"start:dev": "sirv public --dev",
"test": "jest"
"dev:test": "run-p start:test autobuild:test",
"start": "sirv test/sandbox/public -s",
"start:dev": "sirv test/sandbox/public --dev -s",
"start:test": "sirv test/integration/testing-app/public --dev -s --port 3009",
"cy:run": "cypress run",
"cy:open": "cypress open",
"test:integration": "run-p --race dev:test cy:run",
"test:unit": "jest"
},
"jest": {
"verbose": true,
"testMatch": [ "**/*.test.js"],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
},
Expand Down
16 changes: 0 additions & 16 deletions public/index.html

This file was deleted.

50 changes: 0 additions & 50 deletions src/App.svelte

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
let handler

export default class EventManager {
constructor (domNode) {
this._domNode = domNode
this._svgPoint = this._domNode.createSVGPoint()

constructor () {
this._mounted = false
this._clickTracker = new EventTracker(this, 'click')
this._mousemoveTracker = new EventTracker(this, 'mousemove')
this._mousedownTracker = new EventTracker(this, 'mousedown')
this._mouseupTracker = new EventTracker(this, 'mouseup')
this._listeners = {}
}

addRootNode (domNode) {
this._domNode = domNode
this._svgPoint = this._domNode.createSVGPoint()
this._mounted = true
}

attachEventListeners () {
if (this._mounted) {
for (let listenerId in this._listeners) {
let { eventName, callback } = this._listeners[listenerId]
let tracker = this[getTrackerName(eventName)]
tracker.addEventListener(listenerId, callback)
}
} else {
// you should really only call this when mounted
}
}

addEventListener (eventName, listenerId, callback) {
let tracker = this[getTrackerName(eventName)]
tracker.addEventListener(listenerId, callback)
this._listeners[listenerId] = Object.assign({}, { eventName, callback })
if (this._mounted) {
let tracker = this[getTrackerName(eventName)]
tracker.addEventListener(listenerId, callback)
}
}

removeEventListener (eventName, listenerId) {
delete this._listeners[listenerId]
let tracker = this[getTrackerName(eventName)]
tracker.removeEventListener(listenerId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@
}

let rootNode

// set up event and interaction manager
let eventManager = new EventManager()
EventManagerContext.update(eventManagerContext, eventManager)

onMount(() => {
let eventManager = new EventManager(rootNode)
EventManagerContext.update(eventManagerContext, eventManager)
let interactionManager = new InteractionManager()
interactionManager.setId('graphic')
interactionManager.linkEventManager(eventManager)

let interactionManager = new InteractionManager()
interactionManager.setId('graphic')
interactionManager.linkEventManager(eventManager)
InteractionManagerContext.update(interactionManagerContext, interactionManager)

InteractionManagerContext.update(interactionManagerContext, interactionManager)
onMount(() => {
// only on mount can we bind the svg root node and attach actual event listeners
eventManager.addRootNode(rootNode)
eventManager.attachEventListeners()
})
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
</script>

<script>
import { onMount } from 'svelte'

import * as GraphicContext from '../Graphic/GraphicContext'
import * as SectionContext from './SectionContext'
import * as CoordinateTransformationContext from '../CoordinateTransformation/CoordinateTransformationContext'
Expand Down Expand Up @@ -45,14 +43,13 @@
newSectionContext, { sectionId, rangeX, rangeY, scaleX, scaleY }
)
}

// set up interaction manager
let interactionManager = new InteractionManager()
interactionManager.setId(sectionId)
interactionManager.linkEventManager($eventManagerContext)
InteractionManagerContext.update(interactionManagerContext, interactionManager)

onMount(() => {
let interactionManager = new InteractionManager()
interactionManager.setId(sectionId)
interactionManager.linkEventManager($eventManagerContext)

InteractionManagerContext.update(interactionManagerContext, interactionManager)
})
</script>

<g class="section">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
{#if $graphicContext.output() === 'svg'}

<circle
class="point"
cx={$tr_screenGeometry.coordinates[0]}
cy={$tr_screenGeometry.coordinates[1]}
r={$tr_radius}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
{#each indexArray as $index ($index)}

<circle
class="point"
cx={$tr_screenGeometryObject[$index].coordinates[0]}
cy={$tr_screenGeometryObject[$index].coordinates[1]}
r={$tr_radiusObject[$index]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
{#if $graphicContext.output() === 'svg'}

<path
class="polygon"
d={generatePath($tr_screenGeometry)}
fill={$tr_fill}
style={`opacity: ${$tr_opacity}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
{#each indexArray as $index ($index)}

<path
class="polygon"
d={generatePath($tr_screenGeometryObject[$index])}
fill={$tr_fillObject[$index]}
style={`opacity: ${$tr_opacityObject[$index]}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
{#if $graphicContext.output() === 'svg'}

<path
class="rectangle"
d={generatePath($tr_screenGeometry)}
fill={$tr_fill}
style={`opacity: ${$tr_opacity}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@

{#each indexArray as $index ($index)}

<path
<path
class="rectangle"
d={generatePath($tr_screenGeometryObject[$index])}
fill={$tr_fillObject[$index]}
style={`opacity: ${$tr_opacityObject[$index]}`}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { interpolateArray } from 'd3-interpolate'
import pointDistance from '../../../../utils/geometry/pointDistance.js'
import { pointIntersectsLineSegment } from '../../../../utils/geometry/closestPointOnLine.js'
import { pointDistance, pointIntersectsLineSegment } from 'geometryUtils'

export function pointArray (points, transformFunc, visibilityTreshold) {
let interpolatedPoints = []
Expand Down
31 changes: 0 additions & 31 deletions src/florence/utils/geometry/calculateBBox.js

This file was deleted.

Loading