Skip to content

Instantly share code, notes, and snippets.

View CollectiveHealth-gists's full-sized avatar

CollectiveHealth-gists

View GitHub Profile
@CollectiveHealth-gists
CollectiveHealth-gists / caseforsassmaps_bootstrap-buttons.scss
Created July 7, 2017 23:10
The Case for Sass Maps: Bootstrap Buttons
////////////////////////
// Variables
////////////////////////
$btn-default-color: #333;
$btn-default-bg: #fff;
$btn-default-border: #ccc;
$btn-primary-color: #fff;
$btn-primary-bg: $brand-primary;
@CollectiveHealth-gists
CollectiveHealth-gists / caseforsassmaps_sassmap-buttons.scss
Created July 7, 2017 23:12
The Case for Sass Maps: Sass Map Buttons
////////////////////////
// Variables
////////////////////////
$themeColors: (
gray-dark: #333,
gray: #777,
gray-light: #ccc,
white: #fff,
red: #d9534f,
@CollectiveHealth-gists
CollectiveHealth-gists / testingiOS_example-ViewModel.swift
Created July 7, 2017 23:16
Testing iOS at Collective Health: An Example of the View Model for our search results map view
struct SearchResultsMapViewModel {
init(searchLocation loc: SearchLocationDescription?, details: [GetCareProvider])
func getAnnotations() -> [MKAnnotation]
func getProviderForAnnotation(annotation: GetCareAnnotation) -> CollectiveHealth.GetCareProvider?
static func configForAnnotation(annotation: GetCareAnnotation) -> CollectiveHealth.LocationDetailsTableViewModel
@CollectiveHealth-gists
CollectiveHealth-gists / testingiOS_sample-test.swift
Created July 10, 2017 23:29
Testing iOS at Collective Health: A Sample Test
func testAnnotationConfig() {
let providers = generateTestProviders()
let model = SearchResultsMapViewModel(searchLocation: nil, details: providers)
let annotation = model.getAnnotations().first as! GetCareAnnotation
let indexPath = NSIndexPath(forRow: 0, inSection: 0)
let details = SearchResultsMapViewModel.configForAnnotation(annotation)
XCTAssertEqual(details.title, "Bob Boberson")
XCTAssertEqual(details.subtitle, "Plastic Surgery")
@CollectiveHealth-gists
CollectiveHealth-gists / testingiOS_flags-file.swift
Created July 10, 2017 23:30
Testing iOS at Collective Health: A flags file
enum LaunchArguments {
/// Reset our defaults, deletes the persistent store, and clears
/// keychain on launch
static let ResetDefaults = "ResetDefaults"
/// Turn off all animations
static let NoAnimations = "NoAnimations"
/// Get Care Search Result
@CollectiveHealth-gists
CollectiveHealth-gists / testingiOS_keys-launch-arguments.swift
Created July 10, 2017 23:31
Testing iOS at Collective Health: Passing the keys as launch arguments
var app: XCUIApplication!
override func setUp() {
super.setUp()
continueAfterFailure = false
app = XCUIApplication()
app.launchArguments = [
LaunchArguments.ResetDefaults,
@CollectiveHealth-gists
CollectiveHealth-gists / testingiOS_handling-launch-argument.swift
Created July 10, 2017 23:31
Testing iOS at Collective Health: Handling the launch argument
// This method is called from
// `application(didFinishLaunchingWithOptions:)`
private func handleLaunchArguments() {
var arguments = NSProcessInfo.processInfo().arguments
// The first argument is the path of the executable
arguments.removeFirst()
for argument in arguments {
switch argument {
case LaunchArguments.NoAnimations:
@CollectiveHealth-gists
CollectiveHealth-gists / testingiOS_network-stub-code.swift
Created July 10, 2017 23:32
Testing iOS at Collective Health: Our network stub code
func setupSearchResults() {
let testBlock: OHHTTPStubsTestBlock
testBlock = { $0.URL?.path == "/api/v1/getcare/*" }
let fixture = OHPathForFile("GetCareResponse.json", self.dynamicType)!
successResponseBlock = { _ in
return OHHTTPStubsResponse(
fileAtPath: fixture,
statusCode: 200,
headers: ["Content-Type":"application/json"]
@CollectiveHealth-gists
CollectiveHealth-gists / testingiOS_ui-test.swift
Created July 10, 2017 23:39
Testing iOS at Collective Health: A UI Test
func launchApp() {
app.launch()
// We have stubbed out the login flow to always succeed,
// so the password doesn't matter
app.secureTextFields["password_text_field"].typeText("nonsense password\n")
app.tabBars.buttons["get care tab button"].tap()
}
func testCurrentLocationPreSelected() {
@CollectiveHealth-gists
CollectiveHealth-gists / testingiOS_check-element-exists.swift
Created July 10, 2017 23:40
Testing iOS at Collective Health: Checking if an element exists
func assertExists(element: XCUIElement, timeout: NSTimeInterval = 10) {
expectationForPredicate(NSPredicate(format: "exists == 1"),
evaluatedWithObject: element, handler: nil)
waitForExpectationsWithTimeout(timeout, handler: nil)
}