Skip to content

Instantly share code, notes, and snippets.

View fjtrujy's full-sized avatar
🏠
Working from home

Francisco Javier Trujillo Mata fjtrujy

🏠
Working from home
View GitHub Profile
@fjtrujy
fjtrujy / WhatsappStatusCellSnapshotTests.swift
Last active April 29, 2020 13:46
WhatsappStatusCellSnapshotTests - Snapshot Testing
class WhatsappStatusCellSnapshotTests: FBSnapshotTestCase {
let cell = (Bundle.main.loadNibNamed(String(describing: WhatsappStatusCell.self),
owner: nil, options: nil)?.first as! WhatsappStatusCell)
var model: WhatsappStatusSnapshotModel?
var identifier: String?
override func setUp() {
super.setUp()
@fjtrujy
fjtrujy / WhatsappStatusCellSnapshotTests.swift
Last active April 29, 2020 13:49
WhatsappStatusCellSnapshotTests - Prepare generator Section
private let combinations: [WhatsappStatusSnapshotModel] = {
let generator = SnapshotGenerator<WhatsappStatusSnapshotModel>()
let titles = [
"Jhon Smith",
"Paco Perez",
"Dolores Fuertes de Barriga",
"Don Omar",
"Brhadaranyakopanishadvivekachudamani Erreh de la Huerta Castillo",
]
@fjtrujy
fjtrujy / WhatsappStatusSnapshotModel.swift
Last active April 29, 2020 13:52
WhatsappStatusSnapshotModel - Snapshot Testing
import FTMTableSectionModules
class WhatsappStatusSnapshotModel: SnapshotObject {
var imageName: String?
var title: String?
var subtitle: String?
var buttons: Bool?
}
@fjtrujy
fjtrujy / WhatsappStatusCellDecorator.swift
Created April 25, 2020 12:14
WhatsappStatusCellDecorator Init - Snapshot Testing
public init(imageName: String, title: String, subtitle: String, buttons: Bool) {
self.imageName = imageName
self.title = title
self.subtitle = subtitle
self.buttons = buttons
}
@fjtrujy
fjtrujy / WhatsappStatusCellSnapshotTestsBasic.swift
Created April 25, 2020 11:31
WhatsappStatusCellSnapshotTestsBasic - Snapshot Testing
class WhatsappStatusCellSnapshotTestsBasic: FBSnapshotTestCase {
var cell: WhatsappStatusCell?
override func setUp() {
super.setUp()
recordMode = false
let decorator = WhatsappStatusCellDecorator(imageName: "trujy",
title: "Francisco Trujillo",
subtitle: "5 minutes ago",
@fjtrujy
fjtrujy / WhatsappStateModule.swift
Last active April 25, 2020 11:15
WhatsappStateModule - Snapshot Testing
import FTMTableSectionModules
class WhatsappStateModule: TableSectionModule {
private var decorator : WhatsappStateModuleDecorator?
func configure(decorator : WhatsappStateModuleDecorator) {
self.decorator = decorator
createRows()
}
@fjtrujy
fjtrujy / gist:577a51b27a0541dd7491d1ac3371f8aa
Created September 23, 2019 11:11
Extension for AppendUserAgent function
private enum Constants {
static let userAgentJavascript = "navigator.userAgent"
}
extension WKWebView {
func appendUserAgent(_ valueToAppend: String?) {
guard let valueToAppend = valueToAppend else { return }
let group = DispatchGroup()
let queue = DispatchQueue.main
@fjtrujy
fjtrujy / AttributedModule.swift
Created April 27, 2019 16:36
AttributedModule
class AttributedModule: TableSectionModule {
override func registerNibsForCells() -> [AnyClass] {
return super.registerNibsForCells() + [
AttributtedCell.classForCoder(),
]
}
override func createRows() {
super.createRows()
@fjtrujy
fjtrujy / RequestFriendsAttributedDecorator.swift
Created April 27, 2019 16:24
RequestFriendsAttributedDecorator private
//MARK: - RequestFriendsAttributedDecorator
private extension RequestFriendsAttributedDecorator {
var mainColor : UIColor {
return UIColor.black
}
var softColor : UIColor {
return UIColor.gray
}
@fjtrujy
fjtrujy / RequestFriendsAttributedDecorator.swift
Created April 27, 2019 16:22
RequestFriendsAttributedDecorator basic
class RequestFriendsAttributedDecorator: CommonAttributedDecorator {
override func attributedTitle() -> NSAttributedString? {
let attr = NSMutableAttributedString()
attr.append(mainAttributedInfo)
attr.append(attributedBreakLine)
attr.append(descAttributedInfo)
return attr
}
}