mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
refactor: drop two returns that could only ever say one thing
Both functions had two exits handing back the identical value, which reads as a decision and is none — Sonar's S3516, and the last two Blockers on the backend. colorizeImportedTracks returned the very object it was given, coloured in place. Saying `void` and letting the two importers return their own result is what the function was doing all along. PLACES-SVC-005 checked the pass-through and now checks the thing worth checking: an empty import writes no colours. acceptInvite bailed out early on a refusal only to return the same result the line below returns. The notification is what the early exit was really skipping, so it is the notification that gets the condition.
This commit is contained in:
@@ -1157,11 +1157,14 @@ describe('PlacesService — automatic track colours (#776)', () => {
|
||||
expect(new Set(colors).size).toBe(colors.length);
|
||||
});
|
||||
|
||||
it('PLACES-SVC-005 — an import that yields nothing is passed straight through', () => {
|
||||
it('PLACES-SVC-005 — an import that yields nothing colours nothing', () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
expect((svc as any).colorizeImportedTracks(String(trip.id), null)).toBeNull();
|
||||
expect((svc as any).colorizeImportedTracks(String(trip.id), { places: [] })).toEqual({ places: [] });
|
||||
|
||||
expect(() => (svc as any).colorizeImportedTracks(String(trip.id), null)).not.toThrow();
|
||||
expect(() => (svc as any).colorizeImportedTracks(String(trip.id), { places: [] })).not.toThrow();
|
||||
|
||||
expect(tracksOf(trip.id)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user