Skip to content

Commit

Permalink
Refactor station-csv.js to improve code readability and maintainability
Browse files Browse the repository at this point in the history
  • Loading branch information
nikiwycherley committed Aug 7, 2024
1 parent b3d50c0 commit d0db2b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 112 deletions.
40 changes: 5 additions & 35 deletions test/routes/station-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,7 @@ lab.experiment('Routes test - station-csv', () => {
}
]

const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }

sandbox.stub(floodService, 'getStationById').callsFake(fakeStationData)
sandbox.stub(floodService, 'getStationTelemetry').callsFake(fakeTelemetryData)
Expand Down Expand Up @@ -221,13 +215,7 @@ lab.experiment('Routes test - station-csv', () => {
}
]

const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }

sandbox.stub(floodService, 'getStationById').callsFake(fakeStationData)
sandbox.stub(floodService, 'getStationTelemetry').callsFake(fakeTelemetryData)
Expand Down Expand Up @@ -300,13 +288,7 @@ lab.experiment('Routes test - station-csv', () => {
}
]

const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }

sandbox.stub(floodService, 'getStationById').callsFake(fakeStationData)
sandbox.stub(floodService, 'getStationTelemetry').callsFake(fakeTelemetryData)
Expand Down Expand Up @@ -338,13 +320,7 @@ lab.experiment('Routes test - station-csv', () => {
}
]

const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }

sandbox.stub(floodService, 'getStationById').callsFake(fakeStationData)
sandbox.stub(floodService, 'getStationTelemetry').callsFake(fakeTelemetryData)
Expand Down Expand Up @@ -374,13 +350,7 @@ lab.experiment('Routes test - station-csv', () => {
}
]

const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }

sandbox.stub(floodService, 'getStationById').callsFake(fakeStationData)
sandbox.stub(floodService, 'getStationTelemetry').callsFake(fakeTelemetryData)
Expand Down
88 changes: 11 additions & 77 deletions test/routes/station.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,7 @@ lab.experiment('Test - /station/{id}', () => {
forecastactive: false
}
]
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }

const fakeStationForecastData = () => []
const fakeWarningsAlertsData = () => []
Expand Down Expand Up @@ -351,13 +345,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }
const fakeTargetAreasData = () => []
const fakeStationThresholdData = () => []

Expand Down Expand Up @@ -495,13 +483,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }
const fakeWarningsAlertsData = () => []
const fakeStationThresholdData = () => []

Expand Down Expand Up @@ -634,13 +616,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }
const fakeWarningsAlertsData = () => []
const fakeStationThresholdData = () => []

Expand Down Expand Up @@ -738,13 +714,7 @@ lab.experiment('Test - /station/{id}', () => {
const fakeTelemetryData = () => []

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }
const fakeWarningsAlertsData = () => []
const fakeRiverStationData = () => []
const fakeStationThresholdData = () => []
Expand Down Expand Up @@ -878,13 +848,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }
const fakeWarningsAlertsData = () => []
const fakeStationThresholdData = () => []

Expand Down Expand Up @@ -1020,13 +984,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }
const fakeWarningsAlertsData = () => []
const fakeStationThresholdData = () => []

Expand Down Expand Up @@ -1606,13 +1564,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }

const fakeTargetAreasData = () => []
const fakeStationThresholdData = () => []
Expand Down Expand Up @@ -1903,13 +1855,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }

const fakeTargetAreasData = () => []
const fakeStationThresholdData = () => []
Expand Down Expand Up @@ -2043,13 +1989,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }
const fakeTargetAreasData = () => []
const fakeStationThresholdData = () => { return {} }

Expand Down Expand Up @@ -2180,13 +2120,7 @@ lab.experiment('Test - /station/{id}', () => {
]

const fakeImpactsData = () => []
const fakeForecastFlag = () => [{
station_display_time_series_id: '94280',
station_id: '8208',
direction: 'u',
display_time_series: true
}
]
const fakeForecastFlag = () => { return { } }
const fakeTargetAreasData = () => []
const fakeStationThresholdData = () => []

Expand Down

0 comments on commit d0db2b0

Please sign in to comment.