#1017 adds early return toSnapshot test

This commit is contained in:
markhuot
2023-11-28 20:59:45 -05:00
parent da20a62e49
commit 2a54b5819d
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,3 @@
{
"key": " <div class=\"container\">\n <div class=\"row\">\n <div class=\"col-md-12\">\n <h1>Snapshot<\/h1>\n <\/div>\n <\/div>\n <\/div>"
}

View File

@ -103,6 +103,26 @@ test('pass with array', function () {
])->toMatchSnapshot(); ])->toMatchSnapshot();
}); });
test('pass with `toSnapshot`', function () {
TestSuite::getInstance()->snapshots->save(json_encode(['key' => $this->snapshotable], JSON_PRETTY_PRINT));
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function toSnapshot()
{
return json_encode([
'key' => $this->snapshotable,
], JSON_PRETTY_PRINT);
}
};
expect($object)->toMatchSnapshot();
});
test('failures', function () { test('failures', function () {
TestSuite::getInstance()->snapshots->save($this->snapshotable); TestSuite::getInstance()->snapshots->save($this->snapshotable);