Skip to content

CodeEditUI: Added snapshot tests & Keep CircleCI? #482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
workflows:
primary:
jobs:
- test
# - test
- lint
10 changes: 10 additions & 0 deletions CodeEdit.xcodeproj/xcshareddata/xcschemes/CodeEdit.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
ReferencedContainer = "container:CodeEditModules">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CodeEditUITests"
BuildableName = "CodeEditUITests"
BlueprintName = "CodeEditUITests"
ReferencedContainer = "container:CodeEditModules">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
</dict>
</array>
<key>GitHash</key>
<string>f08e8c87a1f981d393377e0380d13afa44366974</string>
<string>31899974c561d1e3a8dad637b2051ef50b5c08f6</string>
</dict>
</plist>
87 changes: 87 additions & 0 deletions CodeEditModules/Modules/CodeEditUI/Tests/UnitTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//
// UnitTests.swift
// CodeEdit
//
// Created by Lukas Pistrol on 19.04.22.
//

@testable import CodeEditUI
import Foundation
import SnapshotTesting
import SwiftUI
import XCTest

final class CodeEditUIUnitTests: XCTestCase {

// MARK: Help Button

func testHelpButtonLight() throws {
let view = HelpButton(action: {})
let hosting = NSHostingView(rootView: view)
hosting.frame = CGRect(origin: .zero, size: .init(width: 40, height: 40))
hosting.appearance = .init(named: .aqua)
assertSnapshot(matching: hosting, as: .image(size: .init(width: 40, height: 40)))
}

func testHelpButtonDark() throws {
let view = HelpButton(action: {})
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 40, height: 40))
assertSnapshot(matching: hosting, as: .image)
}

// MARK: Segmented Control

func testSegmentedControlLight() throws {
let view = SegmentedControl(.constant(0), options: ["Opt1", "Opt2"])
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .aqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 100, height: 30))
assertSnapshot(matching: hosting, as: .image)
}

func testSegmentedControlDark() throws {
let view = SegmentedControl(.constant(0), options: ["Opt1", "Opt2"])
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 100, height: 30))
assertSnapshot(matching: hosting, as: .image)
}

// MARK: FontPickerView

func testFontPickerViewLight() throws {
let view = FontPicker("Font", name: .constant("SF-Mono"), size: .constant(13))
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .aqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 120, height: 30))
assertSnapshot(matching: hosting, as: .image)
}

func testFontPickerViewDark() throws {
let view = FontPicker("Font", name: .constant("SF-Mono"), size: .constant(13))
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 120, height: 30))
assertSnapshot(matching: hosting, as: .image)
}

// MARK: EffectView

func testEffectViewLight() throws {
let view = EffectView()
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .aqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 20, height: 20))
assertSnapshot(matching: hosting, as: .image)
}

func testEffectViewDark() throws {
let view = EffectView()
let hosting = NSHostingView(rootView: view)
hosting.appearance = .init(named: .darkAqua)
hosting.frame = CGRect(origin: .zero, size: .init(width: 20, height: 20))
assertSnapshot(matching: hosting, as: .image)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions CodeEditModules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ let package = Package(
name: "CodeEditUI",
path: "Modules/CodeEditUI/src"
),
.testTarget(
name: "CodeEditUITests",
dependencies: [
"CodeEditUI",
"SnapshotTesting",
],
path: "Modules/CodeEditUI/Tests"
),
.target(
name: "ExtensionsStore",
dependencies: [
Expand Down