Skip to content

Commit

Permalink
test: Migrate places-carousel.spec.js
Browse files Browse the repository at this point in the history
- add map-pin and mockPlaces fixture
- tile requests done by the component are intercepted and a static image returned
- places passed to the component are stripped down to only contain relevant keys
- remove old spec file
  • Loading branch information
TheGreatRefrigerator committed Jan 26, 2023
1 parent d21d1f2 commit c305cee
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 30 deletions.
Binary file added cypress/fixtures/map-pin.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions cypress/fixtures/mockPlaces.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [8.769869, 49.37625]
},
"properties": {
"layer": "locality",
"name": "Heidelberg",
"distance": 0.867,
"country_a": "DEU",
"locality": "Heidelberg",
"label": "Heidelberg, BW, Germany"
},
"bbox": [8.57312513958, 49.3521596612, 8.79412886129, 49.4595876777],
"distance": 0.8655641929890087
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [8.793137, 49.39434]
},
"properties": {
"layer": "venue",
"source": "openstreetmap",
"name": "Sparkasse Heidelberg",
"distance": 2.585,
"country_a": "DEU",
"locality": "Neckargemünd",
"label": "Sparkasse Heidelberg, Neckargemünd, BW, Germany"
},
"bbox": [8.7928299, 49.3941569, 8.7933164, 49.3943459],
"distance": 2.58199841383592
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [8.692416, 49.401247]
},
"properties": {
"layer": "county",
"name": "Heidelberg",
"distance": 5.497,
"country_a": "DEU",
"county": "Heidelberg",
"label": "Heidelberg, BW, Germany"
},
"bbox": [8.573125, 49.35216, 8.794129, 49.459588],
"distance": 5.490898644881834
}
]
24 changes: 24 additions & 0 deletions src/fragments/places-carousel/PlacesCarousel.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import PlacesCarousel from './PlacesCarousel.vue'
import mockPlaces from 'fixtures/mockPlaces.json'
import store from '@/store/store'
import I18nBuilder from '@/i18n/i18n-builder'
import constants from '@/resources/constants'
import MapViewData from '@/models/map-view-data'

const i18n = I18nBuilder.build()


describe('<PlacesCarousel />', () => {
it('renders', () => {
cy.viewport(700, 300)
cy.intercept('GET', `${constants.worldImageryTileProviderBaseUrl}/*/*/*`, {fixture: 'map-pin.jpg'})
cy.mount(PlacesCarousel, {
propsData: {
mapViewData: new MapViewData({places: mockPlaces}), activeIndex: 0
}, i18n: i18n, store: store
})
cy.get('.carousel .vue-horizontal-list')
cy.get('.vhl-list .vhl-item').should('have.length', 3)
cy.get('.item.active')
})
})
30 changes: 0 additions & 30 deletions tests/integration/specs/places-carousel.spec.js

This file was deleted.

0 comments on commit c305cee

Please sign in to comment.