Skip to content

Commit d89b8d9

Browse files
committed
Merge branch 'master' of github.com:json-snapshot/json-snapshot.github.io
# Conflicts: # src/test/java/io/github/jsonSnapshot/SnapshotIntegrationTest.java # src/test/java/io/github/jsonSnapshot/SnapshotIntegrationTest.snap
2 parents e3687d7 + bb0c507 commit d89b8d9

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ Based on [facebook's Jest framework](https://facebook.github.io/jest/docs/en/sna
1818

1919

2020

21-
#### How to install using Maven
21+
#### How to install using [Maven](https://mvnrepository.com/artifact/io.github.json-snapshot/json-snapshot/0.0.1)
22+
23+
2224

2325
Add to your pom.xml dependencies section:
2426

src/test/java/io/github/jsonSnapshot/FakeObject.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.jsonSnapshot;
22

33
import lombok.Builder;
4+
import lombok.Setter;
45

56
@Builder
67
public class FakeObject {
@@ -11,4 +12,7 @@ public class FakeObject {
1112

1213
private String name;
1314

15+
@Setter
16+
private FakeObject fakeObject;
17+
1418
}

src/test/java/io/github/jsonSnapshot/SnapshotIntegrationTest.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,23 @@ public void shouldMatchSnapshotFour() {
4545
}
4646

4747
@Test
48-
public void shouldMatchSnapshotFive() {
48+
public void shouldThrowSnapshotMatchException() {
4949
expectedException.expect(SnapshotMatchException.class);
5050
expectedException.expectMessage(startsWith("Error on: \n" +
51-
"io.github.jsonSnapshot.SnapshotIntegrationTest.shouldMatchSnapshotFive=["));
51+
"io.github.jsonSnapshot.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=["));
5252
expect(FakeObject.builder().id("anyId5").value(6).name("anyName5").build()).toMatchSnapshot();
5353
}
54+
55+
@Test
56+
public void shouldThrowStackOverflowError() {
57+
expectedException.expect(StackOverflowError.class);
58+
59+
// Create cycle JSON
60+
FakeObject fakeObject1 = FakeObject.builder().id("anyId1").value(1).name("anyName1").build();
61+
FakeObject fakeObject2 = FakeObject.builder().id("anyId2").value(2).name("anyName2").build();
62+
fakeObject1.setFakeObject(fakeObject2);
63+
fakeObject2.setFakeObject(fakeObject1);
64+
65+
expect(fakeObject1).toMatchSnapshot();
66+
}
5467
}

src/test/java/io/github/jsonSnapshot/SnapshotIntegrationTest.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
io.github.jsonSnapshot.SnapshotIntegrationTest.shouldMatchSnapshotThree=[
1+
io.github.jsonSnapshot.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=[
22
{
3-
"id": "anyId3",
4-
"value": 3,
5-
"name": "anyName3"
3+
"id": "anyId5",
4+
"value": 5,
5+
"name": "anyName5"
66
}
77
]
88

99

10-
io.github.jsonSnapshot.SnapshotIntegrationTest.shouldMatchSnapshotFive=[
10+
io.github.jsonSnapshot.SnapshotIntegrationTest.shouldMatchSnapshotThree=[
1111
{
12-
"id": "anyId5",
13-
"value": 5,
14-
"name": "anyName5"
12+
"id": "anyId3",
13+
"value": 3,
14+
"name": "anyName3"
1515
}
1616
]
1717

0 commit comments

Comments
 (0)