Skip to content

Commit

Permalink
fix: reset to _initialData
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Oct 30, 2024
1 parent 4c835ed commit 99abe4c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/snapshot/src/port/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export default class SnapshotState {
) {
const { data, dirty } = getSnapshotData(snapshotContent, options)
this._fileExists = snapshotContent != null // TODO: update on watch?
this._initialData = data
this._snapshotData = data
this._initialData = { ...data }
this._snapshotData = { ...data }
this._dirty = dirty
this._inlineSnapshots = []
this._inlineSnapshotStacks = []
Expand Down Expand Up @@ -120,6 +120,9 @@ export default class SnapshotState {
}

clearTest(testName: string): void {
// TODO: key by test.id
// TODO: reset this.added, matched, etc..

this._inlineSnapshots = this._inlineSnapshots.filter(s => s.testName !== testName)
this._inlineSnapshotStacks = this._inlineSnapshotStacks.filter(s => s.testName !== testName)
if (this._counters.has(testName)) {
Expand Down Expand Up @@ -176,8 +179,9 @@ export default class SnapshotState {
}
}

// TODO: not used. remove it
clear(): void {
this._snapshotData = this._initialData
this._snapshotData = { ...this._initialData }
// this._inlineSnapshots = []
this._counters = new Map()
this.added = 0
Expand Down

0 comments on commit 99abe4c

Please sign in to comment.