SPB Git

Repository Public MIT

GlassSheetTests.swift 3.7 KB 89 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP GlassKit7// File             : Tests/SPGlassComponentsTests/GlassSheetTests.swift8// Module           : Tests9// Repository       : https://git.spboucher.ai/sp-glasskit10// Project Website  : https://glass.spboucher.ai11// Created          : 2026-12-0212// Last Modified    : 2026-12-0213//14// Author           : Simon-Pierre Boucher15// Position         : Professor of Finance16// Institution      : Université du Québec en Outaouais (UQO)17// Organization     : SP Boucher18// Website          : https://spboucher.ai19// Git              : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development      : dev@spboucher.ai23// Support          : support@spboucher.ai24// Security/Admin   : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License          : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import SwiftUI42import Testing43@testable import SPGlassComponents4445@Suite("GlassSheet")46struct GlassSheetTests {47    @Test func detentsMapToSystemDetents() {48        #expect(GlassSheetDetent.medium.presentationDetent == .medium)49        #expect(GlassSheetDetent.large.presentationDetent == .large)50        #expect(GlassSheetDetent.fraction(0.3).presentationDetent == .fraction(0.3))51        #expect(GlassSheetDetent.height(320).presentationDetent == .height(320))52    }5354    @Test func outOfRangeValuesAreNormalized() {55        #expect(GlassSheetDetent.fraction(0).normalized == .fraction(0.1))56        #expect(GlassSheetDetent.fraction(-2).normalized == .fraction(0.1))57        #expect(GlassSheetDetent.fraction(1.8).normalized == .fraction(1))58        #expect(GlassSheetDetent.height(10).normalized == .height(44))59        #expect(GlassSheetDetent.height(-.infinity).normalized == .large)60        #expect(GlassSheetDetent.fraction(.nan).normalized == .large)61        #expect(GlassSheetDetent.fraction(7).presentationDetent == .fraction(1))62    }6364    @Test func detentListsBecomeSetsWithoutDuplicates() {65        #expect(GlassSheetDetent.presentationDetents([.medium, .large, .medium]) == [.medium, .large])66        #expect(GlassSheetDetent.presentationDetents([.fraction(2), .fraction(1)]) == [.fraction(1)])67    }6869    @Test func anEmptyListMeansAFullHeightSheet() {70        #expect(GlassSheetDetent.presentationDetents([]) == [.large])71    }7273    @Test func configurationDefaultsKeepAWayOut() {74        let standard = GlassSheetConfiguration.standard75        #expect(standard.showsCloseButton)76        #expect(!standard.isInteractiveDismissDisabled)77        #expect(standard.detents == [.large])78        #expect(GlassSheetConfiguration.halfAndFull.detents == [.medium, .large])79    }8081    @Test func titleBarAppearsForATitleOrACloseButton() {82        var configuration = GlassSheetConfiguration(showsCloseButton: false)83        #expect(!configuration.needsTitleBar(hasTitle: false))84        #expect(configuration.needsTitleBar(hasTitle: true))85        configuration.showsCloseButton = true86        #expect(configuration.needsTitleBar(hasTitle: false))87    }88}89
Files main
Menu

Theme