Skip to content

Commit

Permalink
fix: SearchInfo.allTasks is now independent of the list passed in
Browse files Browse the repository at this point in the history
  • Loading branch information
claremacrae committed Oct 27, 2023
1 parent 1da1a7d commit c631f66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Query/SearchInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export class SearchInfo {
public readonly allTasks: Readonly<Task[]>;

public constructor(allTasks: Task[]) {
this.allTasks = allTasks;
this.allTasks = [...allTasks];
}
}
4 changes: 2 additions & 2 deletions tests/Query/SearchInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SearchInfo } from '../../src/Query/SearchInfo';
import { TaskBuilder } from '../TestingTools/TaskBuilder';

describe('SearchInfo', () => {
it('should not be able to modify the tasks in SearchInfo.allTasks directly', () => {
it('should not be able to modify SearchInfo.allTasks directly', () => {
const tasks = [new TaskBuilder().build()];
const searchInfo = new SearchInfo(tasks);
expect(searchInfo.allTasks.length).toEqual(1);
Expand All @@ -14,7 +14,7 @@ describe('SearchInfo', () => {
// searchInfo.allTasks[0] = new TaskBuilder().description('cannot replace a task').build();
});

it.failing('should not be able to modify the tasks in SearchInfo.allTasks indirectly', () => {
it('should not be able to modify SearchInfo.allTasks indirectly', () => {
const tasks = [new TaskBuilder().build()];
const searchInfo = new SearchInfo(tasks);

Expand Down

0 comments on commit c631f66

Please sign in to comment.