-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): Fix bug when matching double elim playoff matches 2-13 (#72
) Co-authored-by: Evan Strat <[email protected]>
- Loading branch information
Showing
5 changed files
with
109 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { CompLevel } from "@src/models/CompLevel"; | ||
import MatchKey from "@src/models/MatchKey"; | ||
import { PlayoffsType } from "@src/models/PlayoffsType"; | ||
|
||
describe("MatchKey", () => { | ||
it("should parse a valid qualification match key", () => { | ||
const matchkey = MatchKey.fromString("2023gadal_qm16", PlayoffsType.DoubleElimination); | ||
expect(matchkey.compLevel).toEqual(CompLevel.Qualification); | ||
expect(matchkey.eventCode).toEqual("gadal"); | ||
expect(matchkey.matchNumber).toEqual(16); | ||
expect(matchkey.setNumber).toBeNull(); | ||
expect(matchkey.year).toEqual(2023); | ||
}); | ||
|
||
it("should parse valid double elimination playoff match keys", () => { | ||
const sf1m1 = MatchKey.fromString("2023gadal_sf1m1", PlayoffsType.DoubleElimination); | ||
expect(sf1m1.compLevel).toEqual(CompLevel.Semifinal); | ||
expect(sf1m1.eventCode).toEqual("gadal"); | ||
expect(sf1m1.matchNumber).toEqual(1); | ||
expect(sf1m1.setNumber).toEqual(1); | ||
expect(sf1m1.year).toEqual(2023); | ||
|
||
const sf2m1 = MatchKey.fromString("2023gadal_sf2m1", PlayoffsType.DoubleElimination); | ||
expect(sf2m1.compLevel).toEqual(CompLevel.Semifinal); | ||
expect(sf2m1.eventCode).toEqual("gadal"); | ||
expect(sf2m1.matchNumber).toEqual(1); | ||
expect(sf2m1.setNumber).toEqual(2); | ||
expect(sf2m1.year).toEqual(2023); | ||
|
||
const f1m1 = MatchKey.fromString("2023gadal_f1m1", PlayoffsType.DoubleElimination); | ||
expect(f1m1.compLevel).toEqual(CompLevel.Final); | ||
expect(f1m1.eventCode).toEqual("gadal"); | ||
expect(f1m1.matchNumber).toEqual(1); | ||
expect(f1m1.setNumber).toEqual(1); | ||
expect(f1m1.year).toEqual(2023); | ||
|
||
const f1m2 = MatchKey.fromString("2023gadal_f1m2", PlayoffsType.DoubleElimination); | ||
expect(f1m2.compLevel).toEqual(CompLevel.Final); | ||
expect(f1m2.eventCode).toEqual("gadal"); | ||
expect(f1m2.matchNumber).toEqual(2); | ||
expect(f1m2.setNumber).toEqual(1); | ||
expect(f1m2.year).toEqual(2023); | ||
|
||
const f1m3 = MatchKey.fromString("2023gadal_f1m3", PlayoffsType.DoubleElimination); | ||
expect(f1m3.compLevel).toEqual(CompLevel.Final); | ||
expect(f1m3.eventCode).toEqual("gadal"); | ||
expect(f1m3.matchNumber).toEqual(3); | ||
expect(f1m3.setNumber).toEqual(1); | ||
expect(f1m3.year).toEqual(2023); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Test getLocalVideoFilesForMatch function, using mockFs | ||
import { getLocalVideoFilesForMatch } from "@src/services/MatchesService"; | ||
import MatchKey from "@src/models/MatchKey"; | ||
import { PlayoffsType } from "@src/models/PlayoffsType"; | ||
import mockFs from "mock-fs"; | ||
import { sampleSettings } from "../util"; | ||
|
||
const sampleVideos = { | ||
"Qualification 1.mp4": "", | ||
"Qualification 2.mp4": "", | ||
"Qualification 10.mp4": "", | ||
"Playoff 1.mp4": "", | ||
"Playoff 2.mp4": "", | ||
"Playoff 10.mp4": "", | ||
}; | ||
|
||
describe("MatchesService", () => { | ||
it("should return an empty array if no files are found", async () => { | ||
mockFs({ | ||
videos: sampleVideos, | ||
"settings/settings.example.json": JSON.stringify(sampleSettings), | ||
}); | ||
|
||
const files = await getLocalVideoFilesForMatch( | ||
MatchKey.fromString("2023gadal_qm16", PlayoffsType.DoubleElimination), | ||
); | ||
expect(files).toEqual([]); | ||
mockFs.restore(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { type ISettings } from "@src/models/Settings"; | ||
|
||
export const sampleSettings: ISettings = { | ||
eventName: "Example Event", | ||
eventTbaCode: "2023gacmp", | ||
videoSearchDirectory: "./videos", | ||
googleAuthStatus: "", | ||
googleClientId: "", | ||
playoffsType: "Double elimination playoff", | ||
sandboxModeEnabled: false, | ||
youTubeVideoPrivacy: "private", | ||
linkVideosOnTheBlueAlliance: false, | ||
useFrcEventsApi: false, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters