mirror of
https://github.com/rfvgyhn/min-ed-launcher.git
synced 2026-02-04 16:15:45 +00:00
Useful for when FDev makes a copy/paste error for a new product (i.e. when they released Odyssey with an "edh" filter instead of "edo") fixes #25
81 lines
3.5 KiB
Forth
81 lines
3.5 KiB
Forth
module MinEdLauncher.Tests.AuthorizedProduct
|
|
|
|
open MinEdLauncher
|
|
open MinEdLauncher.Types
|
|
open Expecto
|
|
|
|
[<Tests>]
|
|
let tests =
|
|
testList "AuthorizedProduct" [
|
|
testList "fixDirectoryPath" [
|
|
let product =
|
|
{ Name = ""; Filter = ""; Directory = "directory"; GameArgs = ""; ServerArgs = ""; SortKey = 0; Sku = "sku"; TestApi = false }
|
|
|
|
test "Steam prefers Directory over SKU" {
|
|
let directoryExists path = true
|
|
|
|
let actual = AuthorizedProduct.fixDirectoryPath "" Steam directoryExists product
|
|
|
|
Expect.equal actual.Directory product.Directory ""
|
|
}
|
|
test "Steam uses SKU if Directory doesn't exist" {
|
|
let directoryExists path = if path = product.Directory then false else true
|
|
|
|
let actual = AuthorizedProduct.fixDirectoryPath "" Steam directoryExists product
|
|
|
|
Expect.equal actual.Directory product.Sku ""
|
|
}
|
|
test "Epic prefers Directory over SKU" {
|
|
let directoryExists path = true
|
|
|
|
let actual = AuthorizedProduct.fixDirectoryPath "" (Epic EpicDetails.Empty) directoryExists product
|
|
|
|
Expect.equal actual.Directory product.Directory ""
|
|
}
|
|
test "Epic uses SKU if Directory doesn't exist" {
|
|
let directoryExists path = if path = product.Directory then false else true
|
|
|
|
let actual = AuthorizedProduct.fixDirectoryPath "" (Epic EpicDetails.Empty) directoryExists product
|
|
|
|
Expect.equal actual.Directory product.Sku ""
|
|
}
|
|
test "Frontier prefers SKU over directory" {
|
|
let directoryExists path = true
|
|
|
|
let actual = AuthorizedProduct.fixDirectoryPath "" (Frontier FrontierDetails.Empty) directoryExists product
|
|
|
|
Expect.equal actual.Directory product.Sku ""
|
|
}
|
|
test "Frontier uses Directory if SKU doesn't exist" {
|
|
let directoryExists path = if path = product.Sku then false else true
|
|
|
|
let actual = AuthorizedProduct.fixDirectoryPath "" (Frontier FrontierDetails.Empty) directoryExists product
|
|
|
|
Expect.equal actual.Directory product.Directory ""
|
|
}
|
|
]
|
|
|
|
testList "fixFilters" [
|
|
let product =
|
|
{ Name = ""; Filter = "oldFilter"; Directory = ""; GameArgs = ""; ServerArgs = ""; SortKey = 0; Sku = "sku"; TestApi = false }
|
|
test "No change when overrides is empty" {
|
|
let actual = AuthorizedProduct.fixFilters Map.empty product
|
|
|
|
Expect.equal actual product ""
|
|
}
|
|
test "No change when no matching sku" {
|
|
let overrides = [ "asdf", "newFilter" ] |> Map.ofList
|
|
let actual = AuthorizedProduct.fixFilters overrides product
|
|
|
|
Expect.equal actual product ""
|
|
}
|
|
test "Updates filter when matching sku" {
|
|
let newFilter = "newFilter"
|
|
let overrides = [ product.Sku, newFilter ] |> Map.ofList
|
|
let actual = AuthorizedProduct.fixFilters overrides product
|
|
|
|
Expect.equal actual.Filter newFilter ""
|
|
}
|
|
]
|
|
]
|