Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

FBSnapshotTestCase integration. Initial tests for AttributedStringView #688

Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ _site/
# secrets
Resources/*.xcconfig



# FBSnapshotTestCase Failure Diffs
FailureDiffs/
25 changes: 21 additions & 4 deletions Freetime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
29FB94301EE752280016E6D4 /* IssueLabeledCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FB942F1EE752280016E6D4 /* IssueLabeledCell.swift */; };
29FF85A51EE1EA7A007B8762 /* ReactionContent+ReactionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF85A41EE1EA7A007B8762 /* ReactionContent+ReactionType.swift */; };
3E79A2FF1F8A7DA700E1126B /* ShortcutHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E79A2FE1F8A7DA700E1126B /* ShortcutHandler.swift */; };
45A9D03A1F9D3D9600FD5AEF /* AttributedStringViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45A9D0391F9D3D9600FD5AEF /* AttributedStringViewTests.swift */; };
4920F1A81F72E27200131E9D /* UIViewController+UserActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4920F1A71F72E27200131E9D /* UIViewController+UserActivity.swift */; };
49D029001F91D90C00E39094 /* ReactionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49D028FF1F91D90C00E39094 /* ReactionTests.swift */; };
49D029011F91D9C700E39094 /* ReactionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292FCB1C1EDFCD3D0026635E /* ReactionViewModel.swift */; };
Expand Down Expand Up @@ -779,6 +780,7 @@
35E1CE59E98A2C8E7F451CA6 /* Pods-FreetimeTests.testflight.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FreetimeTests.testflight.xcconfig"; path = "Pods/Target Support Files/Pods-FreetimeTests/Pods-FreetimeTests.testflight.xcconfig"; sourceTree = "<group>"; };
3DB749FB402B660C8A9F516C /* Pods_Freetime.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Freetime.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3E79A2FE1F8A7DA700E1126B /* ShortcutHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutHandler.swift; sourceTree = "<group>"; };
45A9D0391F9D3D9600FD5AEF /* AttributedStringViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedStringViewTests.swift; sourceTree = "<group>"; };
4920F1A71F72E27200131E9D /* UIViewController+UserActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+UserActivity.swift"; sourceTree = "<group>"; };
49D028FF1F91D90C00E39094 /* ReactionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionTests.swift; sourceTree = "<group>"; };
49FFF4331F9FC83200335568 /* HapticFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticFeedback.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1306,6 +1308,7 @@
isa = PBXGroup;
children = (
DCA5ED171FAEF3220072F074 /* Bookmark Tests */,
45A9D0381F9D3D6A00FD5AEF /* Snapshot Tests */,
297AE84C1EC0D58A00B44A1F /* DateDisplayTests.swift */,
2981A8A61EFEBEF900E25EF1 /* EmojiTests.swift */,
296B4E331F7C80B800C16887 /* GraphQLIDDecodeTests.swift */,
Expand Down Expand Up @@ -1666,6 +1669,14 @@
path = Labeled;
sourceTree = "<group>";
};
45A9D0381F9D3D6A00FD5AEF /* Snapshot Tests */ = {
isa = PBXGroup;
children = (
45A9D0391F9D3D9600FD5AEF /* AttributedStringViewTests.swift */,
);
path = "Snapshot Tests";
sourceTree = "<group>";
};
7BBFEE551F8A8A0400C68E47 /* SearchBar */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1995,7 +2006,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = $SRCROOT/tools/bump_build_number.sh;
shellScript = "$SRCROOT/tools/bump_build_number.sh";
};
295B51391FC2342200C3993B /* Run Fabric */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -2135,6 +2146,7 @@
"${BUILT_PRODUCTS_DIR}/SwipeCellKit/SwipeCellKit.framework",
"${BUILT_PRODUCTS_DIR}/TUSafariActivity/TUSafariActivity.framework",
"${BUILT_PRODUCTS_DIR}/Tabman/Tabman.framework",
"${BUILT_PRODUCTS_DIR}/FBSnapshotTestCase/FBSnapshotTestCase.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
Expand All @@ -2156,6 +2168,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwipeCellKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TUSafariActivity.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Tabman.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSnapshotTestCase.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -2614,6 +2627,7 @@
29EDFE7C1F65C580005BCCEB /* SplitViewTests.swift in Sources */,
293A459E1F298EE200DD1006 /* IssueCommentHrModel.swift in Sources */,
29DA1E8D1F5F8DCF0050C64B /* MarkdownAttribute.swift in Sources */,
45A9D03A1F9D3D9600FD5AEF /* AttributedStringViewTests.swift in Sources */,
49D029011F91D9C700E39094 /* ReactionViewModel.swift in Sources */,
293A457A1F296B7E00DD1006 /* EmojiTests.swift in Sources */,
293A45901F296CF300DD1006 /* NSAttributedString+Trim.swift in Sources */,
Expand Down Expand Up @@ -2657,6 +2671,7 @@
/* Begin XCBuildConfiguration section */
297AE84F1EC0D58A00B44A1F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 295B512F1FC2230600C3993B /* FREETIME-DEBUG.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -2714,6 +2729,7 @@
};
297AE8501EC0D58A00B44A1F /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 295B512D1FC2230600C3993B /* FREETIME-RELEASE.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -2764,7 +2780,7 @@
};
297AE8521EC0D58A00B44A1F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 295B512F1FC2230600C3993B /* FREETIME-DEBUG.xcconfig */;
baseConfigurationReference = 94840B8CCA6EA8A3EA37FA91 /* Pods-Freetime.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
Expand All @@ -2789,7 +2805,7 @@
};
297AE8531EC0D58A00B44A1F /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 295B512F1FC2230600C3993B /* FREETIME-DEBUG.xcconfig */;
baseConfigurationReference = EA08BE0B8263E4898B1DF86B /* Pods-Freetime.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -2846,6 +2862,7 @@
};
98A8CA991F7451A2009BE6AC /* TestFlight */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 295B512E1FC2230600C3993B /* FREETIME-TESTFLIGHT.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -2896,7 +2913,7 @@
};
98A8CA9A1F7451A2009BE6AC /* TestFlight */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 295B512F1FC2230600C3993B /* FREETIME-DEBUG.xcconfig */;
baseConfigurationReference = B9D4562D9138A112D9EDD9DD /* Pods-Freetime.testflight.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
Expand Down
42 changes: 42 additions & 0 deletions FreetimeTests/Snapshot Tests/AttributedStringViewTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// AttributedStringViewTests.swift
// FreetimeTests
//
// Created by Austinate on 10/22/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//

import XCTest
import FBSnapshotTestCase
@testable import Freetime

class AttributedStringViewTests: FBSnapshotTestCase {
let initialFrame = CGRect(origin: .zero, size: CGSize(width: 320, height: 44))
var view: AttributedStringView!

override func setUp() {
super.setUp()
view = AttributedStringView(frame: initialFrame)
}

func testAttributedStringUIWithSimpleTextIsCorrect() {
let attributed = NSAttributedString(string: "This is just a sample\nof simple\ntext")
let text = NSAttributedStringSizing(containerWidth: initialFrame.width,
attributedText: attributed)
view.configureAndSizeToFit(text: text, width: initialFrame.width)
FBSnapshotVerifyView(view)
}

func testAttributedStringUIEmailIsCorrect() {
let attributes: [NSAttributedStringKey: Any] = [.foregroundColor: UIColor.gray]
let attributedTitle = NSMutableAttributedString(string: "This is sample title with\n email: ",
attributes: attributes)
let email = NSAttributedString(string: "[email protected]",
attributes: [MarkdownAttribute.email: "[email protected]"])
attributedTitle.append(email)
let text = NSAttributedStringSizing(containerWidth: initialFrame.width,
attributedText: attributedTitle)
view.configureAndSizeToFit(text: text, width: initialFrame.width)
FBSnapshotVerifyView(view)
}
}
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 ....AttributedStringViewTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target 'Freetime' do
end

target 'FreetimeTests' do

pod 'FBSnapshotTestCase'
end

post_install do |installer|
Expand Down
35 changes: 21 additions & 14 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ PODS:
- Alamofire (4.4.0)
- AlamofireNetworkActivityIndicator (2.1.0):
- Alamofire (~> 4.1)
- Apollo (0.7.0):
- Apollo/Core (= 0.7.0)
- Apollo/Core (0.7.0)
- Apollo (0.7.0-alpha.9):
- Apollo/Core (= 0.7.0-alpha.9)
- Apollo/Core (0.7.0-alpha.9)
- Crashlytics (3.9.3):
- Fabric (~> 1.7.2)
- Fabric (1.7.2)
- FBSnapshotTestCase (2.1.4):
- FBSnapshotTestCase/SwiftSupport (= 2.1.4)
- FBSnapshotTestCase/Core (2.1.4)
- FBSnapshotTestCase/SwiftSupport (2.1.4):
- FBSnapshotTestCase/Core
- FLAnimatedImage (1.0.12)
- FlatCache (0.1.0)
- FLEX (2.4.0)
Expand All @@ -25,19 +30,19 @@ PODS:
- FLAnimatedImage (~> 1.0.8)
- NYTPhotoViewer/Core
- NYTPhotoViewer/Core (1.1.0)
- Pageboy (2.0.4)
- Pageboy (2.0.0)
- PureLayout (3.0.2)
- SDWebImage/Core (4.0.0)
- SDWebImage/GIF (4.0.0):
- FLAnimatedImage (~> 1.0)
- SDWebImage/Core
- SlackTextViewController (1.9.5)
- SnapKit (4.0.0)
- SwiftLint (0.23.1)
- SwiftLint (0.24.0)
- SwipeCellKit (1.9.0)
- Tabman (1.0.7):
- Pageboy (~> 2.0)
- PureLayout (~> 3.0)
- Tabman (1.0.1):
- Pageboy (~> 2.0.0)
- PureLayout (~> 3.0.0)
- TUSafariActivity (1.0.4)

DEPENDENCIES:
Expand All @@ -46,6 +51,7 @@ DEPENDENCIES:
- Apollo (~> 0.7.0-alpha.5)
- Crashlytics
- Fabric
- FBSnapshotTestCase
- FlatCache (from `Local Pods/FlatCache`)
- FLEX (~> 2.0)
- HTMLString (~> 4.0.1)
Expand Down Expand Up @@ -75,32 +81,33 @@ EXTERNAL SOURCES:

CHECKOUT OPTIONS:
IGListKit:
:commit: b3ffafc018978c20845a3b5aa7b2edb9db8c7622
:commit: 0f04a073194033fbfc6f1d916fad83838042a7c0
:git: https://github.com/Instagram/IGListKit.git

SPEC CHECKSUMS:
Alamofire: dc44b1600b800eb63da6a19039a0083d62a6a62d
AlamofireNetworkActivityIndicator: 4716f6554bdfb9c7cf13b1e0e3af21163129690a
Apollo: d6649ac06168660e70c6226c4eadfc0770791ba5
Apollo: 472b027285e3bd2a79d37d502e98f6f15a3bc528
Crashlytics: dbb07d01876c171c5ccbdf7826410380189e452c
Fabric: 9cd6a848efcf1b8b07497e0b6a2e7d336353ba15
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
FLAnimatedImage: 4a0b56255d9b05f18b6dd7ee06871be5d3b89e31
FlatCache: e67d3d45a0f76b93e66883b802051dcbf9d50649
FLEX: bd1a39e55b56bb413b6f1b34b3c10a0dc44ef079
HTMLString: 8d9a8a8aaf63dd52c5b8cd9a38e14da52f753210
IGListKit: cb97f405ae43e59fe1da74271e19427ec20d3c07
MMMarkdown: 4cf421144508b319a3c7ba6efaa0dcee8e86d9fd
NYTPhotoViewer: e80e8767f3780d2df37c6f72cbab15d6c7232911
Pageboy: 5970f6138b035380fd633b1813b7cc056784b784
Pageboy: a43a4e34fad98ebfa415a5d33cd0389e5005a101
PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd
SDWebImage: 76a6348bdc74eb5a55dd08a091ef298e56b55e41
SlackTextViewController: fbcdadbb8090673f604484ff5b6eb8d77baed42a
SnapKit: a42d492c16e80209130a3379f73596c3454b7694
SwiftLint: 1b670ce79284c76520f84060e87d645078fd32fa
SwiftLint: a014c92b4664e8b13f380f8640a51bb1733778ba
SwipeCellKit: c5199021f354565c955fe8e2f45f79d3b1713e41
Tabman: 9c308875f3e91e1341b103b0665eb17f78f67b4b
Tabman: 627b2bddc6c054bcd86c60919000c30c4adf2ec4
TUSafariActivity: afc55a00965377939107ce4fdc7f951f62454546

PODFILE CHECKSUM: 3ff58bb996077f2aac468142a82d3e740452ff6e
PODFILE CHECKSUM: 42663ce5abae69b05b234e40c92d7f02b29efe06

COCOAPODS: 1.3.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading