From 1fa4d0ab62b2b61db74f3d3b464c60b879dda883 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 14 May 2024 15:47:23 +0200 Subject: [PATCH] Adds test for fields in user --- PadelClubTests/TokenExemptionTests.swift | 1 - PadelClubTests/UserDataTests.swift | 35 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/PadelClubTests/TokenExemptionTests.swift b/PadelClubTests/TokenExemptionTests.swift index 1d28abd..1d87e7a 100644 --- a/PadelClubTests/TokenExemptionTests.swift +++ b/PadelClubTests/TokenExemptionTests.swift @@ -50,7 +50,6 @@ final class TokenExemptionTests: XCTestCase { } func login() async throws -> User { -// print("LOGIN!") let user: User = try await Store.main.service().login(username: self.username, password: self.password) return user } diff --git a/PadelClubTests/UserDataTests.swift b/PadelClubTests/UserDataTests.swift index dd1a999..3b4c11f 100644 --- a/PadelClubTests/UserDataTests.swift +++ b/PadelClubTests/UserDataTests.swift @@ -36,4 +36,39 @@ final class UserDataTests: XCTestCase { } + func login() async throws -> User { + let user: User = try await Store.main.service().login(username: self.username, password: self.password) + return user + } + + func testUserUpdate() async throws { + + let user = try await self.login() + + user.summonsMessageBody = "hello" + user.summonsMessageSignature = "jean coco" + user.summonsAvailablePaymentMethods = "cash" + user.summonsDisplayFormat = true + user.summonsDisplayEntryFee = true + user.summonsUseFullCustomMessage = true + user.matchFormatsDefaultDuration = [MatchFormat.nineGames : 1] + user.bracketMatchFormatPreference = MatchFormat.superTie + user.groupStageMatchFormatPreference = MatchFormat.twoSets + user.loserBracketMatchFormatPreference = MatchFormat.twoSetsOfFourGames + + let uu = try await Store.main.service().put(user) + + assert(uu.summonsMessageBody == user.summonsMessageBody) + assert(uu.summonsMessageSignature == user.summonsMessageSignature) + assert(uu.summonsAvailablePaymentMethods == user.summonsAvailablePaymentMethods) + assert(uu.summonsDisplayFormat == user.summonsDisplayFormat) + assert(uu.summonsDisplayEntryFee == user.summonsDisplayEntryFee) + assert(uu.summonsUseFullCustomMessage == user.summonsUseFullCustomMessage) + assert(uu.matchFormatsDefaultDuration == user.matchFormatsDefaultDuration) + assert(uu.bracketMatchFormatPreference == user.bracketMatchFormatPreference) + assert(uu.groupStageMatchFormatPreference == user.groupStageMatchFormatPreference) + assert(uu.loserBracketMatchFormatPreference == user.loserBracketMatchFormatPreference) + + } + }