Skip to content

Commit 11e7b44

Browse files
committed
update apply method to create path using spread and corner radius.
1 parent 20192a3 commit 11e7b44

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Tests/YCoreUITests/Components/ElevationTests.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ struct Elevation {
3333
self.useShadowPath = useShadowPath
3434
}
3535

36-
func apply(layer: CALayer) {
36+
func apply(layer: CALayer, cornerRadius: CGFloat) {
3737
guard useShadowPath else { return }
3838

39-
layer.shadowPath = UIBezierPath().cgPath
39+
let rect = layer.bounds.insetBy(dx: -spread, dy: -spread)
40+
layer.shadowPath = UIBezierPath(roundedRect: rect, cornerRadius: cornerRadius).cgPath
4041
}
4142
}
4243

@@ -69,7 +70,7 @@ final class ElevationTests: XCTestCase {
6970

7071
let layer = CALayer()
7172

72-
sut.apply(layer: layer)
73+
sut.apply(layer: layer, cornerRadius: 8)
7374

7475
XCTAssertNil(layer.shadowPath)
7576
}
@@ -79,11 +80,13 @@ final class ElevationTests: XCTestCase {
7980

8081
let layer = CALayer()
8182

82-
sut.apply(layer: layer)
83+
sut.apply(layer: layer, cornerRadius: 8)
8384

8485
XCTAssertNotNil(layer.shadowPath)
8586
}
86-
87+
}
88+
89+
private extension ElevationTests {
8790
func makeSUT(offset: CGSize = CGSize(width: 1, height: 1),
8891
blur: CGFloat = 2,
8992
spread: CGFloat = 3,

0 commit comments

Comments
 (0)