Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated interface #762

Merged
merged 2 commits into from
Aug 30, 2023
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
106 changes: 53 additions & 53 deletions Documentation/Available-Snapshot-Strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ A snapshot strategy that captures a value's textual description from `String`'s
#### Example:

``` swift
assertSnapshot(matching: user, as: .description)
assertSnapshot(of: user, as: .description)
```

Records:
Expand All @@ -90,7 +90,7 @@ You can hook into how an instance of a type is rendered in this strategy by conf
#### Example:

``` swift
assertSnapshot(matching: user, as: .dump)
assertSnapshot(of: user, as: .dump)
```

Records:
Expand Down Expand Up @@ -124,10 +124,10 @@ A snapshot strategy for comparing layers based on pixel equality.

``` swift
// Match reference perfectly.
assertSnapshot(matching: layer, as: .image)
assertSnapshot(of: layer, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: layer, as: .image(precision: 0.99))
assertSnapshot(of: layer, as: .image(precision: 0.99))
```

## CaseIterable
Expand Down Expand Up @@ -160,7 +160,7 @@ enum Direction: String, CaseIterable {
}

assertSnapshot(
matching: { $0.rotatedLeft },
of: { $0.rotatedLeft },
as: Snapshotting<Direction, String>.func(into: .description)
)
```
Expand Down Expand Up @@ -194,10 +194,10 @@ A snapshot strategy for comparing paths based on pixel equality.

``` swift
// Match reference perfectly.
assertSnapshot(matching: path, as: .image)
assertSnapshot(of: path, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: path, as: .image(precision: 0.99))
assertSnapshot(of: path, as: .image(precision: 0.99))
```

### `.elementsDescription`
Expand All @@ -216,10 +216,10 @@ A snapshot strategy for comparing paths based on a description of their elements

``` swift
// Match reference perfectly.
assertSnapshot(matching: path, as: .elementsDescription)
assertSnapshot(of: path, as: .elementsDescription)

// Match reference as formatted by formatter.
assertSnapshot(matching: path, as: .elementsDescription(numberFormatter: NumberFormatter()))
assertSnapshot(of: path, as: .elementsDescription(numberFormatter: NumberFormatter()))
```

## Data
Expand All @@ -233,7 +233,7 @@ A snapshot strategy for comparing bare binary data.
#### Example:

``` swift
assertSnapshot(matching: data, as: .data)
assertSnapshot(of: data, as: .data)
```

## Encodable
Expand All @@ -253,7 +253,7 @@ A snapshot strategy for comparing encodable structures based on their JSON repre
#### Example:

``` swift
assertSnapshot(matching: user, as: .json)
assertSnapshot(of: user, as: .json)
```

Records:
Expand All @@ -279,7 +279,7 @@ A snapshot strategy for comparing encodable structures based on their property l
#### Example:

``` swift
assertSnapshot(matching: user, as: .plist)
assertSnapshot(of: user, as: .plist)
```

Records:
Expand Down Expand Up @@ -319,10 +319,10 @@ A snapshot strategy for comparing paths based on pixel equality.

``` swift
// Match reference perfectly.
assertSnapshot(matching: path, as: .image)
assertSnapshot(of: path, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: path, as: .image(precision: 0.99))
assertSnapshot(of: path, as: .image(precision: 0.99))
```

### `.elementsDescription`
Expand All @@ -341,10 +341,10 @@ A snapshot strategy for comparing paths based on a description of their elements

``` swift
// Match reference perfectly.
assertSnapshot(matching: path, as: .elementsDescription)
assertSnapshot(of: path, as: .elementsDescription)

// Match reference as formatted by formatter.
assertSnapshot(matching: path, as: .elementsDescription(numberFormatter: NumberFormatter()))
assertSnapshot(of: path, as: .elementsDescription(numberFormatter: NumberFormatter()))
```

## NSImage
Expand All @@ -367,10 +367,10 @@ A snapshot strategy for comparing images based on pixel equality.

``` swift
// Match reference as-is.
assertSnapshot(matching: image, as: .image)
assertSnapshot(of: image, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: image, as: .image(precision: 0.99))
assertSnapshot(of: image, as: .image(precision: 0.99))
```

## NSView
Expand Down Expand Up @@ -401,14 +401,14 @@ A snapshot strategy for comparing layers based on pixel equality.

``` swift
// Match reference as-is.
assertSnapshot(matching: view, as: .image)
assertSnapshot(of: view, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: view, as: .image(precision: 0.99))
assertSnapshot(of: view, as: .image(precision: 0.99))

// Render at a certain size.
assertSnapshot(
matching: view,
of: view,
as: .image(size: .init(width: 44, height: 44))
)
```
Expand All @@ -422,7 +422,7 @@ A snapshot strategy for comparing views based on a recursive description of thei
#### Example

``` swift
assertSnapshot(matching: view, as: .recursiveDescription)
assertSnapshot(of: view, as: .recursiveDescription)
```

Records:
Expand Down Expand Up @@ -458,14 +458,14 @@ A snapshot strategy for comparing layers based on pixel equality.

``` swift
// Match reference as-is.
assertSnapshot(matching: vc, as: .image)
assertSnapshot(of: vc, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: vc, as: .image(precision: 0.99))
assertSnapshot(of: vc, as: .image(precision: 0.99))

// Render at a certain size.
assertSnapshot(
matching: vc,
of: vc,
as: .image(size: .init(width: 640, height: 480))
)
```
Expand All @@ -481,7 +481,7 @@ A snapshot strategy for comparing view controller views based on a recursive des
#### Example

``` swift
assertSnapshot(matching: vc, as: .recursiveDescription)
assertSnapshot(of: vc, as: .recursiveDescription)
```

Records:
Expand Down Expand Up @@ -515,7 +515,7 @@ A snapshot strategy for comparing SceneKit scenes based on pixel equality.

``` swift
assertSnapshot(
matching: scene,
of: scene,
as: .image(size: .init(width: 640, height: 480))
)
```
Expand Down Expand Up @@ -544,7 +544,7 @@ A snapshot strategy for comparing SpriteKit scenes based on pixel equality.

``` swift
assertSnapshot(
matching: scene,
of: scene,
as: .image(size: .init(width: 640, height: 480))
)
```
Expand All @@ -564,7 +564,7 @@ A snapshot strategy for comparing strings based on equality.
#### Example:

``` swift
assertSnapshot(matching: htmlString, as: .lines)
assertSnapshot(of: htmlString, as: .lines)
```

## UIBezierPath
Expand All @@ -587,10 +587,10 @@ A snapshot strategy for comparing paths based on pixel equality.

``` swift
// Match reference perfectly.
assertSnapshot(matching: path, as: .image)
assertSnapshot(of: path, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: path, as: .image(precision: 0.99))
assertSnapshot(of: path, as: .image(precision: 0.99))
```

### `.elementsDescription`
Expand All @@ -609,10 +609,10 @@ A snapshot strategy for comparing paths based on a description of their elements

``` swift
// Match reference perfectly.
assertSnapshot(matching: path, as: .elementsDescription)
assertSnapshot(of: path, as: .elementsDescription)

// Match reference as formatted by formatter.
assertSnapshot(matching: path, as: .elementsDescription(numberFormatter: NumberFormatter()))
assertSnapshot(of: path, as: .elementsDescription(numberFormatter: NumberFormatter()))
```

## UIImage
Expand All @@ -635,10 +635,10 @@ A snapshot strategy for comparing images based on pixel equality.

``` swift
// Match reference as-is.
assertSnapshot(matching: image, as: .image)
assertSnapshot(of: image, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: image, as: .image(precision: 0.99))
assertSnapshot(of: image, as: .image(precision: 0.99))
```

## UIView
Expand Down Expand Up @@ -677,20 +677,20 @@ A snapshot strategy for comparing layers based on pixel equality.

``` swift
// Match reference as-is.
assertSnapshot(matching: view, as: .image)
assertSnapshot(of: view, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: view, as: .image(precision: 0.99))
assertSnapshot(of: view, as: .image(precision: 0.99))

// Render at a certain size.
assertSnapshot(
matching: view,
of: view,
as: .image(size: .init(width: 44, height: 44))
)

// Render with a horizontally-compact size class.
assertSnapshot(
matching: view,
of: view,
as: .image(traits: .init(horizontalSizeClass: .regular))
)
```
Expand All @@ -715,13 +715,13 @@ A snapshot strategy for comparing views based on a recursive description of thei

``` swift
// Layout on the current device.
assertSnapshot(matching: view, as: .recursiveDescription)
assertSnapshot(of: view, as: .recursiveDescription)

// Layout with a certain size.
assertSnapshot(matching: view, as: .recursiveDescription(size: .init(width: 22, height: 22)))
assertSnapshot(of: view, as: .recursiveDescription(size: .init(width: 22, height: 22)))

// Layout with a certain trait collection.
assertSnapshot(matching: view, as: .recursiveDescription(traits: .init(horizontalSizeClass: .regular)))
assertSnapshot(of: view, as: .recursiveDescription(traits: .init(horizontalSizeClass: .regular)))
```

Records:
Expand All @@ -744,7 +744,7 @@ A snapshot strategy for comparing view controllers based on their embedded contr
#### Example

``` swift
assertSnapshot(matching: vc, as: .hierarchy)
assertSnapshot(of: vc, as: .hierarchy)
```

Records:
Expand Down Expand Up @@ -802,28 +802,28 @@ A snapshot strategy for comparing layers based on pixel equality.

``` swift
// Match reference as-is.
assertSnapshot(matching: vc, as: .image)
assertSnapshot(of: vc, as: .image)

// Allow for a 1% pixel difference.
assertSnapshot(matching: vc, as: .image(precision: 0.99))
assertSnapshot(of: vc, as: .image(precision: 0.99))

// Render as if on a certain device.
assertSnapshot(matching: vc, as: .image(on: .iPhoneX(.portrait)))
assertSnapshot(of: vc, as: .image(on: .iPhoneX(.portrait)))

// Render at a certain size.
assertSnapshot(
matching: vc,
of: vc,
as: .image(size: .init(width: 375, height: 667))
)

// Render with a horizontally-compact size class.
assertSnapshot(
matching: vc,
of: vc,
as: .image(traits: .init(horizontalSizeClass: .compact))
)

// Match reference as-is.
assertSnapshot(matching: vc, as: .image)
assertSnapshot(of: vc, as: .image)
```

**See also**: [`UIView`](#uiview).
Expand Down Expand Up @@ -852,10 +852,10 @@ A snapshot strategy for comparing view controller views based on a recursive des

``` swift
// Layout on the current device.
assertSnapshot(matching: vc, as: .recursiveDescription)
assertSnapshot(of: vc, as: .recursiveDescription)

// Layout as if on a certain device.
assertSnapshot(matching: vc, as: .recursiveDescription(on: .iPhoneSe(.portrait)))
assertSnapshot(of: vc, as: .recursiveDescription(on: .iPhoneSe(.portrait)))
```

Records:
Expand All @@ -878,7 +878,7 @@ A snapshot strategy for comparing requests based on a cURL representation.
#### Example:

``` swift
assertSnapshot(matching: request, as: .curl)
assertSnapshot(of: request, as: .curl)
```

Records:
Expand All @@ -900,7 +900,7 @@ A snapshot strategy for comparing requests based on raw equality.
#### Example:

``` swift
assertSnapshot(matching: request, as: .raw)
assertSnapshot(of: request, as: .raw)
```

Records:
Expand Down
Loading
Loading