Skip to content

Commit

Permalink
WIP: Fixes unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
s4cha committed Sep 20, 2024
1 parent 0523405 commit c3ecd9b
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 51 deletions.
6 changes: 4 additions & 2 deletions Tests/SteviaTests/BaselineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import XCTest
import Stevia

class BaselineTests: XCTestCase {
@MainActor class BaselineTests: XCTestCase {

var win: UIWindow!
var ctrler: UIViewController!
var label1 = UILabel()
var label2 = UILabel()

override func setUp() {
override func setUp() async throws {
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
Expand All @@ -29,6 +29,8 @@ class BaselineTests: XCTestCase {
}
}



func testAlignLastBaselines() {
label1.top(100)
align(lastBaselines: label1, label2)
Expand Down
6 changes: 3 additions & 3 deletions Tests/SteviaTests/CenterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import XCTest

let magicalIphoneXShift = 0.17

class CenterTests: XCTestCase {
@MainActor class CenterTests: XCTestCase {

var win: UIWindow!
var ctrler: UIViewController!
var v: UIView!

override func setUp() {
super.setUp()
override func setUp() async throws {
// try await super.setUp()
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
Expand Down
25 changes: 13 additions & 12 deletions Tests/SteviaTests/ContentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import Stevia

let title = "TitleTest"

class UIButtonContentTests: XCTestCase {
@MainActor class UIButtonContentTests: XCTestCase {
var button = UIButton()

override func setUp() {
super.setUp()
override func setUp() async throws {
//
button = UIButton()
}

Expand All @@ -41,11 +41,12 @@ class UIButtonContentTests: XCTestCase {
}
}

class UILabelContentTests: XCTestCase {

@MainActor class UILabelContentTests: XCTestCase {
var label = UILabel()

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
label = UILabel()
}

Expand All @@ -64,11 +65,11 @@ class UILabelContentTests: XCTestCase {
}
}

class UITextFieldContentTests: XCTestCase {
@MainActor class UITextFieldContentTests: XCTestCase {
var textField = UITextField()

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
textField = UITextField()
}

Expand All @@ -82,11 +83,11 @@ class UITextFieldContentTests: XCTestCase {
}
}

class UIImageViewContentTests: XCTestCase {
@MainActor class UIImageViewContentTests: XCTestCase {
var imageView = UIImageView()

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
imageView = UIImageView()
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/SteviaTests/EquationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import XCTest
import Stevia

class EquationTests: XCTestCase {
@MainActor class EquationTests: XCTestCase {

var win: UIWindow!
var ctrler: UIViewController!

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
Expand Down
6 changes: 3 additions & 3 deletions Tests/SteviaTests/FillTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import XCTest

import Stevia

class FillTests: XCTestCase {
@MainActor class FillTests: XCTestCase {
var win: UIWindow!
var ctrler: UIViewController!

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
Expand Down
6 changes: 3 additions & 3 deletions Tests/SteviaTests/FlexibleMarginTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import XCTest
import Stevia

class FlexibleMarginTests: XCTestCase {
@MainActor class FlexibleMarginTests: XCTestCase {

var win: UIWindow!
var ctrler: UIViewController!
var v: UIView!

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
Expand Down
6 changes: 3 additions & 3 deletions Tests/SteviaTests/FullLayoutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class TestView: UIView {
}
}

class FullLayoutTests: XCTestCase {
@MainActor class FullLayoutTests: XCTestCase {

var win: UIWindow!
var vc: UIViewController!
var v: TestView!

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
win = UIWindow(frame: UIScreen.main.bounds)
vc = UIViewController()///TestVC()
win.rootViewController = vc
Expand Down
22 changes: 11 additions & 11 deletions Tests/SteviaTests/GetConstraintsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import XCTest
import Stevia

class GetConstraintsTests: XCTestCase {
@MainActor class GetConstraintsTests: XCTestCase {

var v: UIView!
var spv: UIView!

override func setUp() {
spv = UIView()
v = UIView()
override func setUp() async throws {
spv = await UIView()
v = await UIView()
spv.subviews { v! }
}

Expand Down Expand Up @@ -68,7 +68,7 @@ class GetConstraintsTests: XCTestCase {
XCTAssertEqual(c?.isActive, true)
}

func testCanGetBottomConstraint() {
@MainActor func testCanGetBottomConstraint() {
XCTAssertNil(v.bottomConstraint)
v.bottom(145)
let c = v.bottomConstraint
Expand All @@ -84,7 +84,7 @@ class GetConstraintsTests: XCTestCase {
XCTAssertEqual(c?.isActive, true)
}

func testCanGetHeightConstraint() {
@MainActor func testCanGetHeightConstraint() {
XCTAssertNil(v.heightConstraint)
v.height(35)
let c = v.heightConstraint
Expand All @@ -100,7 +100,7 @@ class GetConstraintsTests: XCTestCase {
XCTAssertEqual(c?.isActive, true)
}

func testCanGetWidthConstraint() {
@MainActor func testCanGetWidthConstraint() {
XCTAssertNil(v.widthConstraint)
v.width(51)
let c = v.widthConstraint
Expand All @@ -116,7 +116,7 @@ class GetConstraintsTests: XCTestCase {
XCTAssertEqual(c?.isActive, true)
}

func testCanGetTrailingConstraint() {
@MainActor func testCanGetTrailingConstraint() {
XCTAssertNil(v.trailingConstraint)
v.trailingAnchor.constraint(equalTo: spv.trailingAnchor, constant: 104).isActive = true
let c = v.trailingConstraint
Expand All @@ -132,7 +132,7 @@ class GetConstraintsTests: XCTestCase {
XCTAssertEqual(c?.isActive, true)
}

func testCanGetLeadingonstraint() {
@MainActor func testCanGetLeadingonstraint() {
XCTAssertNil(v.leadingConstraint)
v.leadingAnchor.constraint(equalTo: spv.leadingAnchor, constant: 73).isActive = true
let c = v.leadingConstraint
Expand All @@ -148,7 +148,7 @@ class GetConstraintsTests: XCTestCase {
XCTAssertEqual(c?.isActive, true)
}

func testCanGetCenterXConstraint() {
@MainActor func testCanGetCenterXConstraint() {
XCTAssertNil(v.centerXConstraint)
v.CenterX == spv.CenterX + 27
let c = v.centerXConstraint
Expand All @@ -164,7 +164,7 @@ class GetConstraintsTests: XCTestCase {
XCTAssertEqual(c?.isActive, true)
}

func testCanGetCenterYConstraint() {
@MainActor func testCanGetCenterYConstraint() {
XCTAssertNil(v.centerYConstraint)
v.CenterY == spv.CenterY - 32
let c = v.centerYConstraint
Expand Down
2 changes: 1 addition & 1 deletion Tests/SteviaTests/HierarchyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import XCTest
import Stevia

class HierarchyTests: XCTestCase {
@MainActor class HierarchyTests: XCTestCase {

override func setUp() {
super.setUp()
Expand Down
6 changes: 3 additions & 3 deletions Tests/SteviaTests/LayoutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import XCTest
import Stevia

class LayoutTests: XCTestCase {
@MainActor class LayoutTests: XCTestCase {

var win: UIWindow!
var ctrler: UIViewController!
var v: UIView!

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
Expand Down
6 changes: 3 additions & 3 deletions Tests/SteviaTests/PositionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import XCTest
import Stevia

class PositionTests: XCTestCase {
@MainActor class PositionTests: XCTestCase {

var win: UIWindow!
var ctrler: UIViewController!
var v: UIView!

override func setUp() {
super.setUp()
override func setUp() async throws {
// super.setUp()
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
Expand Down
16 changes: 13 additions & 3 deletions Tests/SteviaTests/SizeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@
import XCTest
import Stevia

class SizeTests: XCTestCase {
@MainActor class SizeTests: XCTestCase {

var win: UIWindow!
var ctrler: UIViewController!
var v: UIView!

override func setUp() {
super.setUp()
override func setUp() async throws {
// try await super.setUp()
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
v = UIView()
ctrler.view.subviews {
v!
}
}

func uiSetUp() {
win = UIWindow(frame: UIScreen.main.bounds)
ctrler = UIViewController()
win.rootViewController = ctrler
Expand Down
2 changes: 1 addition & 1 deletion Tests/SteviaTests/StyleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import XCTest
import Stevia

class StyleTests: XCTestCase {
@MainActor class StyleTests: XCTestCase {

func styleView(_ view: UIView) {
view.backgroundColor = UIColor.yellow
Expand Down

0 comments on commit c3ecd9b

Please sign in to comment.