Move module funcs to properties
This commit is contained in:
@@ -39,8 +39,8 @@ let asOfDateDisplayTests =
|
||||
[<Tests>]
|
||||
let churchTests =
|
||||
testList "Church" [
|
||||
test "empty is as expected" {
|
||||
let mt = Church.empty
|
||||
test "Empty is as expected" {
|
||||
let mt = Church.Empty
|
||||
Expect.equal mt.Id.Value Guid.Empty "The church ID should have been an empty GUID"
|
||||
Expect.equal mt.Name "" "The name should have been blank"
|
||||
Expect.equal mt.City "" "The city should have been blank"
|
||||
@@ -111,16 +111,16 @@ let expirationTests =
|
||||
let listPreferencesTests =
|
||||
testList "ListPreferences" [
|
||||
test "FontStack is correct for native fonts" {
|
||||
Expect.equal ListPreferences.empty.FontStack
|
||||
Expect.equal ListPreferences.Empty.FontStack
|
||||
"""system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,"Liberation Sans",Cantarell,"Helvetica Neue",sans-serif"""
|
||||
"The expected native font stack was incorrect"
|
||||
}
|
||||
test "FontStack is correct for specific fonts" {
|
||||
Expect.equal { ListPreferences.empty with Fonts = "Arial,sans-serif" }.FontStack "Arial,sans-serif"
|
||||
Expect.equal { ListPreferences.Empty with Fonts = "Arial,sans-serif" }.FontStack "Arial,sans-serif"
|
||||
"The specified fonts were not returned correctly"
|
||||
}
|
||||
test "empty is as expected" {
|
||||
let mt = ListPreferences.empty
|
||||
test "Empty is as expected" {
|
||||
let mt = ListPreferences.Empty
|
||||
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
||||
Expect.equal mt.DaysToExpire 14 "The default days to expire should have been 14"
|
||||
Expect.equal mt.DaysToKeepNew 7 "The default days to keep new should have been 7"
|
||||
@@ -137,8 +137,7 @@ let listPreferencesTests =
|
||||
Expect.equal mt.GroupPassword "" "The default group password should have been blank"
|
||||
Expect.equal mt.DefaultEmailType HtmlFormat "The default e-mail type should have been HTML"
|
||||
Expect.isFalse mt.IsPublic "The isPublic flag should not have been set"
|
||||
Expect.equal (TimeZoneId.toString mt.TimeZoneId) "America/Denver"
|
||||
"The default time zone should have been America/Denver"
|
||||
Expect.equal (string mt.TimeZoneId) "America/Denver" "The default time zone should have been America/Denver"
|
||||
Expect.equal mt.PageSize 100 "The default page size should have been 100"
|
||||
Expect.equal mt.AsOfDateDisplay NoDisplay "The as-of date display should have been No Display"
|
||||
}
|
||||
@@ -147,8 +146,8 @@ let listPreferencesTests =
|
||||
[<Tests>]
|
||||
let memberTests =
|
||||
testList "Member" [
|
||||
test "empty is as expected" {
|
||||
let mt = Member.empty
|
||||
test "Empty is as expected" {
|
||||
let mt = Member.Empty
|
||||
Expect.equal mt.Id.Value Guid.Empty "The member ID should have been an empty GUID"
|
||||
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
||||
Expect.equal mt.Name "" "The member name should have been blank"
|
||||
@@ -162,8 +161,8 @@ let prayerRequestTests =
|
||||
let instantNow = SystemClock.Instance.GetCurrentInstant
|
||||
let localDateNow () = (instantNow ()).InUtc().Date
|
||||
testList "PrayerRequest" [
|
||||
test "empty is as expected" {
|
||||
let mt = PrayerRequest.empty
|
||||
test "Empty is as expected" {
|
||||
let mt = PrayerRequest.Empty
|
||||
Expect.equal mt.Id.Value Guid.Empty "The request ID should have been an empty GUID"
|
||||
Expect.equal mt.RequestType CurrentRequest "The request type should have been Current"
|
||||
Expect.equal mt.UserId.Value Guid.Empty "The user ID should have been an empty GUID"
|
||||
@@ -175,59 +174,60 @@ let prayerRequestTests =
|
||||
Expect.isFalse mt.NotifyChaplain "The notify chaplain flag should not have been set"
|
||||
Expect.equal mt.Expiration Automatic "The expiration should have been Automatic"
|
||||
}
|
||||
test "isExpired always returns false for expecting requests" {
|
||||
PrayerRequest.isExpired (localDateNow ()) SmallGroup.empty
|
||||
{ PrayerRequest.empty with RequestType = Expecting }
|
||||
test "IsExpired always returns false for expecting requests" {
|
||||
{ PrayerRequest.Empty with RequestType = Expecting }.IsExpired (localDateNow ()) SmallGroup.Empty
|
||||
|> Flip.Expect.isFalse "An expecting request should never be considered expired"
|
||||
}
|
||||
test "isExpired always returns false for manually-expired requests" {
|
||||
PrayerRequest.isExpired (localDateNow ()) SmallGroup.empty
|
||||
{ PrayerRequest.empty with UpdatedDate = (instantNow ()) - Duration.FromDays 1; Expiration = Manual }
|
||||
test "IsExpired always returns false for manually-expired requests" {
|
||||
{ PrayerRequest.Empty with
|
||||
UpdatedDate = (instantNow ()) - Duration.FromDays 1
|
||||
Expiration = Manual }.IsExpired (localDateNow ()) SmallGroup.Empty
|
||||
|> Flip.Expect.isFalse "A never-expired request should never be considered expired"
|
||||
}
|
||||
test "isExpired always returns false for long term/recurring requests" {
|
||||
PrayerRequest.isExpired (localDateNow ()) SmallGroup.empty
|
||||
{ PrayerRequest.empty with RequestType = LongTermRequest }
|
||||
test "IsExpired always returns false for long term/recurring requests" {
|
||||
{ PrayerRequest.Empty with RequestType = LongTermRequest }.IsExpired (localDateNow ()) SmallGroup.Empty
|
||||
|> Flip.Expect.isFalse "A recurring/long-term request should never be considered expired"
|
||||
}
|
||||
test "isExpired always returns true for force-expired requests" {
|
||||
PrayerRequest.isExpired (localDateNow ()) SmallGroup.empty
|
||||
{ PrayerRequest.empty with UpdatedDate = (instantNow ()); Expiration = Forced }
|
||||
test "IsExpired always returns true for force-expired requests" {
|
||||
{ PrayerRequest.Empty with UpdatedDate = (instantNow ()); Expiration = Forced }.IsExpired
|
||||
(localDateNow ()) SmallGroup.Empty
|
||||
|> Flip.Expect.isTrue "A force-expired request should always be considered expired"
|
||||
}
|
||||
test "isExpired returns false for non-expired requests" {
|
||||
test "IsExpired returns false for non-expired requests" {
|
||||
let now = instantNow ()
|
||||
PrayerRequest.isExpired (now.InUtc().Date) SmallGroup.empty
|
||||
{ PrayerRequest.empty with UpdatedDate = now - Duration.FromDays 5 }
|
||||
{ PrayerRequest.Empty with UpdatedDate = now - Duration.FromDays 5 }.IsExpired
|
||||
(now.InUtc().Date) SmallGroup.Empty
|
||||
|> Flip.Expect.isFalse "A request updated 5 days ago should not be considered expired"
|
||||
}
|
||||
test "isExpired returns true for expired requests" {
|
||||
test "IsExpired returns true for expired requests" {
|
||||
let now = instantNow ()
|
||||
PrayerRequest.isExpired (now.InUtc().Date) SmallGroup.empty
|
||||
{ PrayerRequest.empty with UpdatedDate = now - Duration.FromDays 15 }
|
||||
{ PrayerRequest.Empty with UpdatedDate = now - Duration.FromDays 15 }.IsExpired
|
||||
(now.InUtc().Date) SmallGroup.Empty
|
||||
|> Flip.Expect.isTrue "A request updated 15 days ago should be considered expired"
|
||||
}
|
||||
test "isExpired returns true for same-day expired requests" {
|
||||
test "IsExpired returns true for same-day expired requests" {
|
||||
let now = instantNow ()
|
||||
PrayerRequest.isExpired (now.InUtc().Date) SmallGroup.empty
|
||||
{ PrayerRequest.empty with UpdatedDate = now - (Duration.FromDays 14) - (Duration.FromSeconds 1L) }
|
||||
{ PrayerRequest.Empty with
|
||||
UpdatedDate = now - (Duration.FromDays 14) - (Duration.FromSeconds 1L) }.IsExpired
|
||||
(now.InUtc().Date) SmallGroup.Empty
|
||||
|> Flip.Expect.isTrue "A request entered a second before midnight should be considered expired"
|
||||
}
|
||||
test "updateRequired returns false for expired requests" {
|
||||
PrayerRequest.updateRequired (localDateNow ()) SmallGroup.empty
|
||||
{ PrayerRequest.empty with Expiration = Forced }
|
||||
test "UpdateRequired returns false for expired requests" {
|
||||
{ PrayerRequest.Empty with Expiration = Forced }.UpdateRequired (localDateNow ()) SmallGroup.Empty
|
||||
|> Flip.Expect.isFalse "An expired request should not require an update"
|
||||
}
|
||||
test "updateRequired returns false when an update is not required for an active request" {
|
||||
test "UpdateRequired returns false when an update is not required for an active request" {
|
||||
let now = instantNow ()
|
||||
PrayerRequest.updateRequired (localDateNow ()) SmallGroup.empty
|
||||
{ PrayerRequest.empty with RequestType = LongTermRequest; UpdatedDate = now - Duration.FromDays 14 }
|
||||
{ PrayerRequest.Empty with
|
||||
RequestType = LongTermRequest
|
||||
UpdatedDate = now - Duration.FromDays 14 }.UpdateRequired (localDateNow ()) SmallGroup.Empty
|
||||
|> Flip.Expect.isFalse "An active request updated 14 days ago should not require an update until 28 days"
|
||||
}
|
||||
test "UpdateRequired returns true when an update is required for an active request" {
|
||||
let now = instantNow ()
|
||||
PrayerRequest.updateRequired (localDateNow ()) SmallGroup.empty
|
||||
{ PrayerRequest.empty with RequestType = LongTermRequest; UpdatedDate = now - Duration.FromDays 34 }
|
||||
{ PrayerRequest.Empty with
|
||||
RequestType = LongTermRequest
|
||||
UpdatedDate = now - Duration.FromDays 34 }.UpdateRequired (localDateNow ()) SmallGroup.Empty
|
||||
|> Flip.Expect.isTrue "An active request updated 34 days ago should require an update (past 28 days)"
|
||||
}
|
||||
]
|
||||
@@ -311,8 +311,8 @@ let smallGroupTests =
|
||||
let now = Instant.FromDateTimeUtc (DateTime (2017, 5, 12, 12, 15, 0, DateTimeKind.Utc))
|
||||
let withFakeClock f () =
|
||||
FakeClock now |> f
|
||||
yield test "empty is as expected" {
|
||||
let mt = SmallGroup.empty
|
||||
yield test "Empty is as expected" {
|
||||
let mt = SmallGroup.Empty
|
||||
Expect.equal mt.Id.Value Guid.Empty "The small group ID should have been an empty GUID"
|
||||
Expect.equal mt.ChurchId.Value Guid.Empty "The church ID should have been an empty GUID"
|
||||
Expect.equal mt.Name "" "The name should have been blank"
|
||||
@@ -321,31 +321,31 @@ let smallGroupTests =
|
||||
"LocalTimeNow adjusts the time ahead of UTC",
|
||||
fun clock ->
|
||||
let grp =
|
||||
{ SmallGroup.empty with
|
||||
Preferences = { ListPreferences.empty with TimeZoneId = TimeZoneId "Europe/Berlin" }
|
||||
{ SmallGroup.Empty with
|
||||
Preferences = { ListPreferences.Empty with TimeZoneId = TimeZoneId "Europe/Berlin" }
|
||||
}
|
||||
Expect.isGreaterThan (SmallGroup.localTimeNow clock grp) (now.InUtc().LocalDateTime)
|
||||
Expect.isGreaterThan (grp.LocalTimeNow clock) (now.InUtc().LocalDateTime)
|
||||
"UTC to Europe/Berlin should have added hours"
|
||||
"LocalTimeNow adjusts the time behind UTC",
|
||||
fun clock ->
|
||||
Expect.isLessThan (SmallGroup.localTimeNow clock SmallGroup.empty) (now.InUtc().LocalDateTime)
|
||||
Expect.isLessThan (SmallGroup.Empty.LocalTimeNow clock) (now.InUtc().LocalDateTime)
|
||||
"UTC to America/Denver should have subtracted hours"
|
||||
"LocalTimeNow returns UTC when the time zone is invalid",
|
||||
fun clock ->
|
||||
let grp =
|
||||
{ SmallGroup.empty with
|
||||
Preferences = { ListPreferences.empty with TimeZoneId = TimeZoneId "garbage" }
|
||||
{ SmallGroup.Empty with
|
||||
Preferences = { ListPreferences.Empty with TimeZoneId = TimeZoneId "garbage" }
|
||||
}
|
||||
Expect.equal (SmallGroup.localTimeNow clock grp) (now.InUtc().LocalDateTime)
|
||||
Expect.equal (grp.LocalTimeNow clock) (now.InUtc().LocalDateTime)
|
||||
"UTC should have been returned for an invalid time zone"
|
||||
]
|
||||
yield test "localTimeNow fails when clock is not passed" {
|
||||
Expect.throws (fun () -> (SmallGroup.localTimeNow null SmallGroup.empty |> ignore))
|
||||
Expect.throws (fun () -> SmallGroup.Empty.LocalTimeNow null |> ignore)
|
||||
"Should have raised an exception for null clock"
|
||||
}
|
||||
yield test "LocalDateNow returns the date portion" {
|
||||
let clock = FakeClock (Instant.FromDateTimeUtc (DateTime (2017, 5, 12, 1, 15, 0, DateTimeKind.Utc)))
|
||||
Expect.isLessThan (SmallGroup.localDateNow clock SmallGroup.empty) (now.InUtc().Date)
|
||||
Expect.isLessThan (SmallGroup.Empty.LocalDateNow clock) (now.InUtc().Date)
|
||||
"The date should have been a day earlier"
|
||||
}
|
||||
]
|
||||
@@ -353,8 +353,8 @@ let smallGroupTests =
|
||||
[<Tests>]
|
||||
let userTests =
|
||||
testList "User" [
|
||||
test "empty is as expected" {
|
||||
let mt = User.empty
|
||||
test "Empty is as expected" {
|
||||
let mt = User.Empty
|
||||
Expect.equal mt.Id.Value Guid.Empty "The user ID should have been an empty GUID"
|
||||
Expect.equal mt.FirstName "" "The first name should have been blank"
|
||||
Expect.equal mt.LastName "" "The last name should have been blank"
|
||||
@@ -363,7 +363,7 @@ let userTests =
|
||||
Expect.equal mt.PasswordHash "" "The password hash should have been blank"
|
||||
}
|
||||
test "Name concatenates first and last names" {
|
||||
let user = { User.empty with FirstName = "Unit"; LastName = "Test" }
|
||||
let user = { User.Empty with FirstName = "Unit"; LastName = "Test" }
|
||||
Expect.equal user.Name "Unit Test" "The full name should be the first and last, separated by a space"
|
||||
}
|
||||
]
|
||||
@@ -371,8 +371,8 @@ let userTests =
|
||||
[<Tests>]
|
||||
let userSmallGroupTests =
|
||||
testList "UserSmallGroup" [
|
||||
test "empty is as expected" {
|
||||
let mt = UserSmallGroup.empty
|
||||
test "Empty is as expected" {
|
||||
let mt = UserSmallGroup.Empty
|
||||
Expect.equal mt.UserId.Value Guid.Empty "The user ID should have been an empty GUID"
|
||||
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ let countAll _ = true
|
||||
|
||||
|
||||
module ReferenceListTests =
|
||||
|
||||
|
||||
[<Tests>]
|
||||
let asOfDateListTests =
|
||||
testList "ReferenceList.asOfDateList" [
|
||||
@@ -43,7 +43,7 @@ module ReferenceListTests =
|
||||
Expect.equal (fst lst) (string PlainTextFormat) "The 3rd option should have been plain text"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
[<Tests>]
|
||||
let expirationListTests =
|
||||
testList "ReferenceList.expirationList" [
|
||||
@@ -66,7 +66,7 @@ module ReferenceListTests =
|
||||
"The option for immediate expiration was not found"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
[<Tests>]
|
||||
let requestTypeListTests =
|
||||
testList "ReferenceList.requestTypeList" [
|
||||
@@ -129,7 +129,7 @@ let appViewInfoTests =
|
||||
let assignGroupsTests =
|
||||
testList "AssignGroups" [
|
||||
test "fromUser populates correctly" {
|
||||
let usr = { User.empty with Id = (Guid.NewGuid >> UserId) (); FirstName = "Alice"; LastName = "Bob" }
|
||||
let usr = { User.Empty with Id = (Guid.NewGuid >> UserId) (); FirstName = "Alice"; LastName = "Bob" }
|
||||
let asg = AssignGroups.fromUser usr
|
||||
Expect.equal asg.UserId (shortGuid usr.Id.Value) "The user ID was not filled correctly"
|
||||
Expect.equal asg.UserName usr.Name "The user's name was not filled correctly"
|
||||
@@ -142,7 +142,7 @@ let editChurchTests =
|
||||
testList "EditChurch" [
|
||||
test "fromChurch populates correctly when interface exists" {
|
||||
let church =
|
||||
{ Church.empty with
|
||||
{ Church.Empty with
|
||||
Id = (Guid.NewGuid >> ChurchId) ()
|
||||
Name = "Unit Test"
|
||||
City = "Testlandia"
|
||||
@@ -163,7 +163,7 @@ let editChurchTests =
|
||||
test "fromChurch populates correctly when interface does not exist" {
|
||||
let edit =
|
||||
EditChurch.fromChurch
|
||||
{ Church.empty with
|
||||
{ Church.Empty with
|
||||
Id = (Guid.NewGuid >> ChurchId) ()
|
||||
Name = "Unit Test"
|
||||
City = "Testlandia"
|
||||
@@ -198,7 +198,7 @@ let editChurchTests =
|
||||
HasInterface = Some true
|
||||
InterfaceAddress = Some "https://test.units"
|
||||
}
|
||||
let church = edit.PopulateChurch Church.empty
|
||||
let church = edit.PopulateChurch Church.Empty
|
||||
Expect.notEqual (shortGuid church.Id.Value) edit.ChurchId "The church ID should not have been modified"
|
||||
Expect.equal church.Name edit.Name "The church name was not updated correctly"
|
||||
Expect.equal church.City edit.City "The church's city was not updated correctly"
|
||||
@@ -213,7 +213,7 @@ let editChurchTests =
|
||||
Name = "Test Baptist Church"
|
||||
City = "Testerville"
|
||||
State = "TE"
|
||||
}.PopulateChurch Church.empty
|
||||
}.PopulateChurch Church.Empty
|
||||
Expect.isFalse church.HasVpsInterface "The church should show that it has an interface"
|
||||
Expect.isNone church.InterfaceAddress "The interface address should exist"
|
||||
}
|
||||
@@ -224,7 +224,7 @@ let editMemberTests =
|
||||
testList "EditMember" [
|
||||
test "fromMember populates with group default format" {
|
||||
let mbr =
|
||||
{ Member.empty with
|
||||
{ Member.Empty with
|
||||
Id = (Guid.NewGuid >> MemberId) ()
|
||||
Name = "Test Name"
|
||||
Email = "test_units@example.com"
|
||||
@@ -236,7 +236,7 @@ let editMemberTests =
|
||||
Expect.equal edit.Format "" "The e-mail format should have been blank for group default"
|
||||
}
|
||||
test "fromMember populates with specific format" {
|
||||
let edit = EditMember.fromMember { Member.empty with Format = Some HtmlFormat }
|
||||
let edit = EditMember.fromMember { Member.Empty with Format = Some HtmlFormat }
|
||||
Expect.equal edit.Format (string HtmlFormat) "The e-mail format was not filled correctly"
|
||||
}
|
||||
test "empty is as expected" {
|
||||
@@ -259,7 +259,7 @@ let editMemberTests =
|
||||
let editPreferencesTests =
|
||||
testList "EditPreferences" [
|
||||
test "fromPreferences succeeds for native fonts, named colors, and private list" {
|
||||
let prefs = ListPreferences.empty
|
||||
let prefs = ListPreferences.Empty
|
||||
let edit = EditPreferences.fromPreferences prefs
|
||||
Expect.equal edit.ExpireDays prefs.DaysToExpire "The expiration days were not filled correctly"
|
||||
Expect.equal edit.DaysToKeepNew prefs.DaysToKeepNew "The days to keep new were not filled correctly"
|
||||
@@ -278,7 +278,7 @@ let editPreferencesTests =
|
||||
Expect.isNone edit.Fonts "The list fonts should not exist for native font stack"
|
||||
Expect.equal edit.HeadingFontSize prefs.HeadingFontSize "The heading font size was not filled correctly"
|
||||
Expect.equal edit.ListFontSize prefs.TextFontSize "The list text font size was not filled correctly"
|
||||
Expect.equal edit.TimeZone (TimeZoneId.toString prefs.TimeZoneId) "The time zone was not filled correctly"
|
||||
Expect.equal edit.TimeZone (string prefs.TimeZoneId) "The time zone was not filled correctly"
|
||||
Expect.isSome edit.GroupPassword "The group password should have been set"
|
||||
Expect.equal edit.GroupPassword (Some prefs.GroupPassword) "The group password was not filled correctly"
|
||||
Expect.equal edit.Visibility GroupVisibility.PrivateList
|
||||
@@ -287,7 +287,7 @@ let editPreferencesTests =
|
||||
Expect.equal edit.AsOfDate (string prefs.AsOfDateDisplay) "The as-of date display was not filled correctly"
|
||||
}
|
||||
test "fromPreferences succeeds for RGB line color and password-protected list" {
|
||||
let prefs = { ListPreferences.empty with LineColor = "#ff0000"; GroupPassword = "pw" }
|
||||
let prefs = { ListPreferences.Empty with LineColor = "#ff0000"; GroupPassword = "pw" }
|
||||
let edit = EditPreferences.fromPreferences prefs
|
||||
Expect.equal edit.LineColorType "RGB" "The heading line color type was not derived correctly"
|
||||
Expect.equal edit.LineColor prefs.LineColor "The heading line color was not filled correctly"
|
||||
@@ -297,7 +297,7 @@ let editPreferencesTests =
|
||||
"The list visibility was not derived correctly"
|
||||
}
|
||||
test "fromPreferences succeeds for RGB text color and public list" {
|
||||
let prefs = { ListPreferences.empty with HeadingColor = "#0000ff"; IsPublic = true }
|
||||
let prefs = { ListPreferences.Empty with HeadingColor = "#0000ff"; IsPublic = true }
|
||||
let edit = EditPreferences.fromPreferences prefs
|
||||
Expect.equal edit.HeadingColorType "RGB" "The heading text color type was not derived correctly"
|
||||
Expect.equal edit.HeadingColor prefs.HeadingColor "The heading text color was not filled correctly"
|
||||
@@ -307,7 +307,7 @@ let editPreferencesTests =
|
||||
"The list visibility was not derived correctly"
|
||||
}
|
||||
test "fromPreferences succeeds for non-native fonts" {
|
||||
let prefs = { ListPreferences.empty with Fonts = "Arial,sans-serif" }
|
||||
let prefs = { ListPreferences.Empty with Fonts = "Arial,sans-serif" }
|
||||
let edit = EditPreferences.fromPreferences prefs
|
||||
Expect.isFalse edit.IsNative "The IsNative flag should have been false"
|
||||
Expect.isSome edit.Fonts "The fonts should have been filled for non-native fonts"
|
||||
@@ -330,7 +330,7 @@ let editRequestTests =
|
||||
}
|
||||
test "fromRequest succeeds" {
|
||||
let req =
|
||||
{ PrayerRequest.empty with
|
||||
{ PrayerRequest.Empty with
|
||||
Id = (Guid.NewGuid >> PrayerRequestId) ()
|
||||
RequestType = CurrentRequest
|
||||
Requestor = Some "Me"
|
||||
@@ -358,7 +358,7 @@ let editSmallGroupTests =
|
||||
testList "EditSmallGroup" [
|
||||
test "fromGroup succeeds" {
|
||||
let grp =
|
||||
{ SmallGroup.empty with
|
||||
{ SmallGroup.Empty with
|
||||
Id = (Guid.NewGuid >> SmallGroupId) ()
|
||||
Name = "test group"
|
||||
ChurchId = (Guid.NewGuid >> ChurchId) ()
|
||||
@@ -387,7 +387,7 @@ let editSmallGroupTests =
|
||||
Name = "test name"
|
||||
ChurchId = (Guid.NewGuid >> shortGuid) ()
|
||||
}
|
||||
let grp = edit.populateGroup SmallGroup.empty
|
||||
let grp = edit.populateGroup SmallGroup.Empty
|
||||
Expect.equal grp.Name edit.Name "The name was not populated correctly"
|
||||
Expect.equal grp.ChurchId (idFromShort ChurchId edit.ChurchId) "The church ID was not populated correctly"
|
||||
}
|
||||
@@ -408,7 +408,7 @@ let editUserTests =
|
||||
}
|
||||
test "fromUser succeeds" {
|
||||
let usr =
|
||||
{ User.empty with
|
||||
{ User.Empty with
|
||||
Id = (Guid.NewGuid >> UserId) ()
|
||||
FirstName = "user"
|
||||
LastName = "test"
|
||||
@@ -438,7 +438,7 @@ let editUserTests =
|
||||
Password = "testpw"
|
||||
}
|
||||
let hasher = fun x -> x + "+"
|
||||
let usr = edit.PopulateUser User.empty hasher
|
||||
let usr = edit.PopulateUser User.Empty hasher
|
||||
Expect.equal usr.FirstName edit.FirstName "The first name was not populated correctly"
|
||||
Expect.equal usr.LastName edit.LastName "The last name was not populated correctly"
|
||||
Expect.equal usr.Email edit.Email "The e-mail address was not populated correctly"
|
||||
@@ -500,26 +500,26 @@ let requestListTests =
|
||||
let withRequestList f () =
|
||||
let today = SystemClock.Instance.GetCurrentInstant ()
|
||||
{ Requests = [
|
||||
{ PrayerRequest.empty with
|
||||
{ PrayerRequest.Empty with
|
||||
RequestType = CurrentRequest
|
||||
Requestor = Some "Zeb"
|
||||
Text = "zyx"
|
||||
UpdatedDate = today
|
||||
}
|
||||
{ PrayerRequest.empty with
|
||||
{ PrayerRequest.Empty with
|
||||
RequestType = CurrentRequest
|
||||
Requestor = Some "Aaron"
|
||||
Text = "abc"
|
||||
UpdatedDate = today - Duration.FromDays 9
|
||||
}
|
||||
{ PrayerRequest.empty with
|
||||
{ PrayerRequest.Empty with
|
||||
RequestType = PraiseReport
|
||||
Text = "nmo"
|
||||
UpdatedDate = today
|
||||
}
|
||||
]
|
||||
Date = today.InUtc().Date
|
||||
SmallGroup = SmallGroup.empty
|
||||
SmallGroup = SmallGroup.Empty
|
||||
ShowHeader = false
|
||||
Recipients = []
|
||||
CanEmail = false
|
||||
@@ -596,10 +596,10 @@ let requestListTests =
|
||||
}
|
||||
let html = htmlList.AsHtml _s
|
||||
let expected =
|
||||
htmlList.Requests[0].UpdatedDate.InZone(SmallGroup.timeZone reqList.SmallGroup).Date.ToString ("d", null)
|
||||
htmlList.Requests[0].UpdatedDate.InZone(reqList.SmallGroup.TimeZone).Date.ToString ("d", null)
|
||||
|> sprintf """<strong>Zeb</strong> – zyx<i style="font-size:9.60pt"> (as of %s)</i>"""
|
||||
// spot check; if one request has it, they all should
|
||||
Expect.stringContains html expected "Expected short as-of date not found"
|
||||
Expect.stringContains html expected "Expected short as-of date not found"
|
||||
"AsHtml succeeds with long as-of date",
|
||||
fun reqList ->
|
||||
let htmlList =
|
||||
@@ -611,10 +611,10 @@ let requestListTests =
|
||||
}
|
||||
let html = htmlList.AsHtml _s
|
||||
let expected =
|
||||
htmlList.Requests[0].UpdatedDate.InZone(SmallGroup.timeZone reqList.SmallGroup).Date.ToString ("D", null)
|
||||
htmlList.Requests[0].UpdatedDate.InZone(reqList.SmallGroup.TimeZone).Date.ToString ("D", null)
|
||||
|> sprintf """<strong>Zeb</strong> – zyx<i style="font-size:9.60pt"> (as of %s)</i>"""
|
||||
// spot check; if one request has it, they all should
|
||||
Expect.stringContains html expected "Expected long as-of date not found"
|
||||
Expect.stringContains html expected "Expected long as-of date not found"
|
||||
"AsText succeeds with no as-of date",
|
||||
fun reqList ->
|
||||
let textList = { reqList with SmallGroup = { reqList.SmallGroup with Name = "Test Group" } }
|
||||
@@ -642,10 +642,10 @@ let requestListTests =
|
||||
}
|
||||
let text = textList.AsText _s
|
||||
let expected =
|
||||
textList.Requests[0].UpdatedDate.InZone(SmallGroup.timeZone reqList.SmallGroup).Date.ToString ("d", null)
|
||||
textList.Requests[0].UpdatedDate.InZone(reqList.SmallGroup.TimeZone).Date.ToString ("d", null)
|
||||
|> sprintf " + Zeb - zyx (as of %s)"
|
||||
// spot check; if one request has it, they all should
|
||||
Expect.stringContains text expected "Expected short as-of date not found"
|
||||
Expect.stringContains text expected "Expected short as-of date not found"
|
||||
"AsText succeeds with long as-of date",
|
||||
fun reqList ->
|
||||
let textList =
|
||||
@@ -657,10 +657,10 @@ let requestListTests =
|
||||
}
|
||||
let text = textList.AsText _s
|
||||
let expected =
|
||||
textList.Requests[0].UpdatedDate.InZone(SmallGroup.timeZone reqList.SmallGroup).Date.ToString ("D", null)
|
||||
textList.Requests[0].UpdatedDate.InZone(reqList.SmallGroup.TimeZone).Date.ToString ("D", null)
|
||||
|> sprintf " + Zeb - zyx (as of %s)"
|
||||
// spot check; if one request has it, they all should
|
||||
Expect.stringContains text expected "Expected long as-of date not found"
|
||||
Expect.stringContains text expected "Expected long as-of date not found"
|
||||
"IsNew succeeds for both old and new requests",
|
||||
fun reqList ->
|
||||
let allReqs = reqList.RequestsByType _s
|
||||
|
||||
Reference in New Issue
Block a user