Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Nov 15, 2024
1 parent 8cd5695 commit a2f816b
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import { MapContainer } from 'react-leaflet'
import ImageMarkerLayer from './ImageMarkerLayer'

describe('ImageMarkerLayer Component', () => {
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => {})
})
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => {})
})

afterAll(() => {
console.error.mockRestore()
})
afterAll(() => {
console.error.mockRestore()
})

const mockImages = [
{ key: 'image1', url: 'http://example.com/image1.jpg', position: { lat: 1, lon: 1 } },
{ key: 'image2', url: 'http://example.com/image2.jpg', position: { lat: 2, lon: 2 } },
]
const mockImages = [
{ key: 'image1', url: 'http://example.com/image1.jpg', position: { lat: 1, lon: 1 } },
{ key: 'image2', url: 'http://example.com/image2.jpg', position: { lat: 2, lon: 2 } },
]

it('renders without crashing', () => {
const { container } = render(
<MapContainer>
<ImageMarkerLayer images={mockImages} />
</MapContainer>
)
expect(container).toBeInTheDocument()
})
it('renders without crashing', () => {
const { container } = render(
<MapContainer>
<ImageMarkerLayer images={mockImages} />
</MapContainer>
)
expect(container).toBeInTheDocument()
})
})
34 changes: 17 additions & 17 deletions src/components/MapillaryViewer/MapillaryViewer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import React from 'react'
import { render } from '@testing-library/react'
import MapillaryViewer from './MapillaryViewer'

jest.mock('mapillary-js', () => {
return {
Viewer: jest.fn().mockImplementation(() => ({
setImageId: jest.fn(),
remove: jest.fn(),
})),
}
jest.mock('mapillary-js', () => {
return {
Viewer: jest.fn().mockImplementation(() => ({
setImageId: jest.fn(),
remove: jest.fn(),
})),
}
})

describe('MapillaryViewer Component', () => {
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => {})
})
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => {})
})

afterAll(() => {
console.error.mockRestore()
})
afterAll(() => {
console.error.mockRestore()
})

it('renders without crashing', () => {
const { container } = render(<MapillaryViewer initialImageKey="abc123" />)
expect(container).toBeInTheDocument()
})
it('renders without crashing', () => {
const { container } = render(<MapillaryViewer initialImageKey="abc123" />)
expect(container).toBeInTheDocument()
})
})
28 changes: 14 additions & 14 deletions src/components/Modal/Modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import { render } from '@testing-library/react'
import Modal from './Modal'

describe('Modal Component', () => {
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => {})
})
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => {})
})

afterAll(() => {
console.error.mockRestore()
})
afterAll(() => {
console.error.mockRestore()
})

it('renders without crashing', () => {
const { container } = render(<Modal isActive={true} onClose={() => {}} />)
expect(container).toBeInTheDocument()
})
it('renders without crashing', () => {
const { container } = render(<Modal isActive={true} onClose={() => {}} />)
expect(container).toBeInTheDocument()
})

it('displays the modal content', () => {
const { getByText } = render(<Modal isActive={true} onClose={() => {}}>Modal Content</Modal>)
expect(getByText(/modal content/i)).toBeInTheDocument()
})
it('displays the modal content', () => {
const { getByText } = render(<Modal isActive={true} onClose={() => {}}>Modal Content</Modal>)
expect(getByText(/modal content/i)).toBeInTheDocument()
})
})
160 changes: 80 additions & 80 deletions src/components/OpenStreetCamViewer/OpenStreetCamViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,98 +13,98 @@ import BusySpinner from '../BusySpinner/BusySpinner'
* @author [Neil Rotstan](https://github.com/nrotstan)
*/
const OpenStreetCamViewer = ({ images, initialImageKey, onClose }) => {
const [currentIndex, setCurrentIndex] = useState(-1)
const [imageLoaded, setImageLoaded] = useState(false)
const [currentIndex, setCurrentIndex] = useState(-1)
const [imageLoaded, setImageLoaded] = useState(false)

useEffect(() => {
setCurrentIndex(_findIndex(images, { key: initialImageKey }))
}, [images, initialImageKey])
useEffect(() => {
setCurrentIndex(_findIndex(images, { key: initialImageKey }))
}, [images, initialImageKey])

const hasNextImage = () => currentIndex !== -1 && currentIndex < images.length - 1
const hasPriorImage = () => currentIndex !== -1 && currentIndex > 0
const hasNextImage = () => currentIndex !== -1 && currentIndex < images.length - 1
const hasPriorImage = () => currentIndex !== -1 && currentIndex > 0

const nextImage = () => {
if (hasNextImage()) {
setCurrentIndex(currentIndex + 1)
setImageLoaded(false)
}
}
const nextImage = () => {
if (hasNextImage()) {
setCurrentIndex(currentIndex + 1)
setImageLoaded(false)
}
}

const priorImage = () => {
if (hasPriorImage()) {
setCurrentIndex(currentIndex - 1)
setImageLoaded(false)
}
}
const priorImage = () => {
if (hasPriorImage()) {
setCurrentIndex(currentIndex - 1)
setImageLoaded(false)
}
}

const currentImage = currentIndex === -1 ? null : images[currentIndex]
const currentImage = currentIndex === -1 ? null : images[currentIndex]

return (
<External>
<Modal isActive onClose={onClose}>
<div className="mr-flex mr-flex-col mr-justify-center">
<div className="mr-flex mr-justify-center">
<div className="mr-flex mr-justify-between mr-bg-black-15 mr-rounded mr-p-2">
<div>
{hasPriorImage() &&
<button onClick={priorImage}>
<SvgSymbol
sym="arrow-left-icon"
viewBox='0 0 20 20'
className="mr-h-4 mr-w-4 mr-fill-current"
/>
</button>
}
</div>
return (
<External>
<Modal isActive onClose={onClose}>
<div className="mr-flex mr-flex-col mr-justify-center">
<div className="mr-flex mr-justify-center">
<div className="mr-flex mr-justify-between mr-bg-black-15 mr-rounded mr-p-2">
<div>
{hasPriorImage() &&
<button onClick={priorImage}>
<SvgSymbol
sym="arrow-left-icon"
viewBox='0 0 20 20'
className="mr-h-4 mr-w-4 mr-fill-current"
/>
</button>
}
</div>

<div className="mr-w-4" />
<div className="mr-w-4" />

<div>
{hasNextImage() &&
<button onClick={nextImage}>
<SvgSymbol
sym="arrow-right-icon"
viewBox='0 0 20 20'
className="mr-h-4 mr-w-4 mr-fill-current"
/>
</button>
}
</div>
</div>
</div>
<div>
{hasNextImage() &&
<button onClick={nextImage}>
<SvgSymbol
sym="arrow-right-icon"
viewBox='0 0 20 20'
className="mr-h-4 mr-w-4 mr-fill-current"
/>
</button>
}
</div>
</div>
</div>

<div className="mr-mt-2">
{currentImage &&
<img
src={currentImage.url}
onLoad={() => setImageLoaded(true)}
alt=""
className="mr-w-full mr-h-auto mr-rounded mr-shadow"
/>
}
</div>
<div className="mr-flex mr-justify-center mr-mt-2 mr-min-h-4 mr-text-sm mr-text-white">
{!imageLoaded ?
<BusySpinner /> :
<div className="mr-flex mr-items-center">
<div className="mr-pr-4 mr-mr-4 mr-leading-tight mr-border-r mr-border-grey">
@{currentImage.username}
</div>
<div>
{format(parseISO(currentImage.shotDate), 'yyyy-MM-dd')}
</div>
</div>
}
</div>
</div>
</Modal>
</External>
)
<div className="mr-mt-2">
{currentImage &&
<img
src={currentImage.url}
onLoad={() => setImageLoaded(true)}
alt=""
className="mr-w-full mr-h-auto mr-rounded mr-shadow"
/>
}
</div>
<div className="mr-flex mr-justify-center mr-mt-2 mr-min-h-4 mr-text-sm mr-text-white">
{!imageLoaded ?
<BusySpinner /> :
<div className="mr-flex mr-items-center">
<div className="mr-pr-4 mr-mr-4 mr-leading-tight mr-border-r mr-border-grey">
@{currentImage.username}
</div>
<div>
{format(parseISO(currentImage.shotDate), 'yyyy-MM-dd')}
</div>
</div>
}
</div>
</div>
</Modal>
</External>
)
}

OpenStreetCamViewer.propTypes = {
images: PropTypes.array.isRequired,
onClose: PropTypes.func,
images: PropTypes.array.isRequired,
onClose: PropTypes.func,
}

export default OpenStreetCamViewer
20 changes: 10 additions & 10 deletions src/components/OpenStreetCamViewer/OpenStreetCamViewer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { render } from '@testing-library/react'
import OpenStreetCamViewer from './OpenStreetCamViewer'

describe('OpenStreetCamViewer Component', () => {
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => {})
})
beforeAll(() => {
jest.spyOn(console, 'error').mockImplementation(() => {})
})

afterAll(() => {
console.error.mockRestore()
})
afterAll(() => {
console.error.mockRestore()
})

it('renders without crashing', () => {
const { container } = render(<OpenStreetCamViewer initialImageKey="xyz456" />)
expect(container).toBeInTheDocument()
})
it('renders without crashing', () => {
const { container } = render(<OpenStreetCamViewer initialImageKey="xyz456" />)
expect(container).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion src/components/TaskPane/TaskMap/TaskMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export const TaskMapContent = (props) => {
}
}
}

/**
* Invoked by LayerToggle when the user wishes to toggle visibility of
* OpenStreetCam markers on or off.
Expand Down
Loading

0 comments on commit a2f816b

Please sign in to comment.