Skip to content

Commit

Permalink
fix: dump with filter regression (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed May 9, 2023
1 parent ba9f1ec commit 2e7a021
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions __tests__/__snapshots__/dump.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,12 @@ exports[`#dump() > with a glob pattern > should return files that matches the pa
},
}
`;

exports[`#dump() > with custom filter > should match snapshot 1`] = `
{
"foo/not-committed": {
"contents": "not-committed",
"state": "modified",
},
}
`;
6 changes: 6 additions & 0 deletions __tests__/dump.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ describe('#dump()', () => {
expect(fs.dump(output)).toMatchSnapshot();
});

describe('with custom filter', () => {
it('should match snapshot', () => {
expect(fs.dump(output, file => file.path.endsWith('not-committed'))).toMatchSnapshot();
});
});

describe('with a glob pattern', () => {
it('should return files that matches the pattern and have state or stateCleared', () => {
expect(fs.dump(output, '**/*committed')).toMatchSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion src/actions/dump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function <EditorFile extends MemFsEditorFile>(
const filterFile: (file: EditorFile, cwd: string) => boolean =
typeof filter === 'string'
? (file: MemFsEditorFile) => defaultDumpFilter(file) && minimatch(file.path, filter)
: defaultDumpFilter;
: filter ?? defaultDumpFilter;

return Object.fromEntries(
this.store
Expand Down

0 comments on commit 2e7a021

Please sign in to comment.