-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create snapshot unit tests for card list
- Loading branch information
Axel Collard Bovy
committed
Aug 2, 2023
1 parent
2ef3a2c
commit f7532e4
Showing
30 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
Backpack-SwiftUI/Tests/Images.xcassets/carousel_placeholder_1.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "carousel_placeholder_1.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+317 KB
...ests/Images.xcassets/carousel_placeholder_1.imageset/carousel_placeholder_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
Backpack-SwiftUI/Tests/Images.xcassets/carousel_placeholder_2.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "carousel_placeholder_2.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+214 KB
...ests/Images.xcassets/carousel_placeholder_2.imageset/carousel_placeholder_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
Backpack-SwiftUI/Tests/Images.xcassets/carousel_placeholder_3.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "carousel_placeholder_3.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+273 KB
...ests/Images.xcassets/carousel_placeholder_3.imageset/carousel_placeholder_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
Backpack-SwiftUI/Tests/Images.xcassets/carousel_placeholder_4.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "carousel_placeholder_4.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+242 KB
...ests/Images.xcassets/carousel_placeholder_4.imageset/carousel_placeholder_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
* Backpack - Skyscanner's Design System | ||
* | ||
* Copyright 2018 Skyscanner Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import XCTest | ||
import SnapshotTesting | ||
import SwiftUI | ||
import Backpack_SwiftUI | ||
|
||
class BPKCardListViewTests: XCTestCase { | ||
func testCardListRail() { | ||
assertSnapshot( | ||
BPKCardList( | ||
title: "Section title", | ||
description: "Description about this section (optional)", | ||
layout: .rail, | ||
initiallyShownCards: 2, | ||
totalElements: 4, | ||
cardForIndex: locationContent(index:)) | ||
.padding() | ||
) | ||
} | ||
|
||
func testCardListRailWithSectionHeaderButton() { | ||
assertSnapshot( | ||
BPKCardList( | ||
title: "Section title", | ||
description: "Description about this section (optional)", | ||
sectionHeaderButton: .init(title: "Action", action: { | ||
print("Section header action pressed") | ||
}), | ||
layout: .rail, | ||
initiallyShownCards: 2, | ||
totalElements: 4, | ||
cardForIndex: locationContent(index:)) | ||
.padding() | ||
) | ||
} | ||
|
||
func testCardListStack() { | ||
assertSnapshot( | ||
BPKCardList( | ||
title: "Section title", | ||
description: "Description about this section (optional)", | ||
layout: .stack(nil), | ||
initiallyShownCards: 2, | ||
totalElements: 4, | ||
cardForIndex: locationContent(index:)) | ||
.padding() | ||
) | ||
} | ||
|
||
func testCardListStackWithButtonAccessory() { | ||
assertSnapshot( | ||
BPKCardList( | ||
title: "Section title", | ||
description: "Description about this section (optional)", | ||
layout: .stack( | ||
.button( | ||
.init( | ||
title: "Action", | ||
action: { | ||
print("Section header action pressed") | ||
} | ||
) | ||
) | ||
), | ||
initiallyShownCards: 2, | ||
totalElements: 4, | ||
cardForIndex: locationContent(index:)) | ||
.padding() | ||
) | ||
} | ||
|
||
func testCardListStackWithExpandAccessory() { | ||
assertSnapshot( | ||
BPKCardList( | ||
title: "Section title", | ||
description: "Description about this section (optional)", | ||
layout: .stack(.expand("Show more", "Show less")), | ||
initiallyShownCards: 2, | ||
totalElements: 4, | ||
cardForIndex: locationContent(index:)) | ||
.padding() | ||
) | ||
} | ||
|
||
func testCardListStackWithSectionHeaderButton() { | ||
assertSnapshot( | ||
BPKCardList( | ||
title: "Section title", | ||
description: "Description about this section (optional)", | ||
sectionHeaderButton: .init(title: "Action", action: { | ||
print("Section header action pressed") | ||
}), | ||
layout: .stack(nil), | ||
initiallyShownCards: 2, | ||
totalElements: 4, | ||
cardForIndex: locationContent(index:)) | ||
.padding() | ||
) | ||
} | ||
|
||
func testCardListStackWithExpandAccessoryAndSectionHeaderButton() { | ||
assertSnapshot( | ||
BPKCardList( | ||
title: "Section title", | ||
description: "Description about this section (optional)", | ||
layout: .stack(.expand("Show more", "Show less")), | ||
initiallyShownCards: 2, | ||
totalElements: 4, | ||
cardForIndex: locationContent(index:)) | ||
.padding() | ||
) | ||
} | ||
|
||
private func locationContent(index: Int) -> some View { | ||
BPKCard(padding: .none) { | ||
HStack { | ||
Image("carousel_placeholder_\(index % 4 + 1)", bundle: TestsBundle.bundle) | ||
.resizable() | ||
.aspectRatio(1, contentMode: .fit) | ||
VStack { | ||
Text("Location \(index)") | ||
} | ||
Spacer() | ||
} | ||
} | ||
.frame(height: 90) | ||
} | ||
} |
Binary file added
BIN
+402 KB
CardList/__Snapshots__/BPKCardListViewTests/testCardListRail.dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+399 KB
CardList/__Snapshots__/BPKCardListViewTests/testCardListRail.light-mode.png
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.
Binary file added
BIN
+404 KB
...ts__/BPKCardListViewTests/testCardListRailWithSectionHeaderButton.dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+401 KB
...s__/BPKCardListViewTests/testCardListRailWithSectionHeaderButton.light-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+401 KB
...napshots__/BPKCardListViewTests/testCardListRailWithSectionHeaderButton.rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+197 KB
CardList/__Snapshots__/BPKCardListViewTests/testCardListStack.dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+199 KB
CardList/__Snapshots__/BPKCardListViewTests/testCardListStack.light-mode.png
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.
Binary file added
BIN
+202 KB
...shots__/BPKCardListViewTests/testCardListStackWithButtonAccessory.dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
...hots__/BPKCardListViewTests/testCardListStackWithButtonAccessory.light-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
...__Snapshots__/BPKCardListViewTests/testCardListStackWithButtonAccessory.rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+202 KB
...shots__/BPKCardListViewTests/testCardListStackWithExpandAccessory.dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+204 KB
...hots__/BPKCardListViewTests/testCardListStackWithExpandAccessory.light-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
...__Snapshots__/BPKCardListViewTests/testCardListStackWithExpandAccessory.rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+202 KB
...wTests/testCardListStackWithExpandAccessoryAndSectionHeaderButton.dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+204 KB
...Tests/testCardListStackWithExpandAccessoryAndSectionHeaderButton.light-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
...istViewTests/testCardListStackWithExpandAccessoryAndSectionHeaderButton.rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
...s__/BPKCardListViewTests/testCardListStackWithSectionHeaderButton.dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+205 KB
...__/BPKCardListViewTests/testCardListStackWithSectionHeaderButton.light-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+204 KB
...apshots__/BPKCardListViewTests/testCardListStackWithSectionHeaderButton.rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.