Skip to content

Commit

Permalink
Fix tests after Next.js upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
danactive committed Oct 31, 2022
1 parent 6f21ed1 commit d95906e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions next/src/components/Img/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ describe('<Img />', () => {
expect(image).toHaveClass(className)
})

test('should not adopt a srcset attribute', () => {
const srcset = 'test-HD.png 2x'
const { image } = renderComponent({ srcset })
expect(image).not.toHaveAttribute('srcset')
})
// Next.js uses srcset
// test('should not adopt a srcset attribute', () => {
// const srcset = 'test-HD.png 2x'
// const { image } = renderComponent({ srcset })
// expect(image).not.toHaveAttribute('srcset')
// })
})
3 changes: 2 additions & 1 deletion next/src/components/Img/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function Img({
height = config.resizeDimensions.thumb.height,
title,
}) {
if (!alt) console.error('Missing ALT attribute on IMG') // eslint-disable-line no-console
// Next.js image is now handling alt attribute check
// if (!alt) console.error('Missing ALT attribute on IMG') // eslint-disable-line no-console
return <Image className={className} src={src} alt={alt} width={width} height={height} title={title} />
}

Expand Down
8 changes: 4 additions & 4 deletions next/src/components/SlippyMap/__tests__/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ describe('Options - <SlippyMap />', () => {

test('All Valid coordinates', () => {
const items = [{ coordinates: [123, 321] }, { coordinates: [321, 123], coordinateAccuracy: 10 }]
const received = transformSourceOptions({ items })
const received = transformSourceOptions({ items, selected: items[1] })
const features = [
{
geometry: { coordinates: [123, 321], type: 'Point' },
properties: { accuracy: undefined },
properties: {},
type: 'Feature',
},
{
geometry: { coordinates: [321, 123], type: 'Point' },
properties: { accuracy: 10 },
properties: { selected: true },
type: 'Feature',
},
]
Expand All @@ -46,7 +46,7 @@ describe('Options - <SlippyMap />', () => {
const features = [
{
geometry: { coordinates: [321, 123], type: 'Point' },
properties: { accuracy: 10 },
properties: {},
type: 'Feature',
},
]
Expand Down
2 changes: 1 addition & 1 deletion next/src/components/SlippyMap/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const validatePoint = (rawCoordinate) => {
}
}

export function transformSourceOptions({ items = [], selected } = {}) {
export function transformSourceOptions({ items = [], selected = {} } = {}) {
const geoJsonFeature = (item) => {
const { latitude, longitude } = validatePoint(item.coordinates)
const { latitude: selectedLatitude, longitude: selectedLongitude } = validatePoint(selected.coordinates)
Expand Down

0 comments on commit d95906e

Please sign in to comment.