diff --git a/src/Query/SearchInfo.ts b/src/Query/SearchInfo.ts index ae5dc3b8af..ef302e72d2 100644 --- a/src/Query/SearchInfo.ts +++ b/src/Query/SearchInfo.ts @@ -13,6 +13,6 @@ export class SearchInfo { public readonly allTasks: Readonly; public constructor(allTasks: Task[]) { - this.allTasks = allTasks; + this.allTasks = [...allTasks]; } } diff --git a/tests/Query/SearchInfo.test.ts b/tests/Query/SearchInfo.test.ts index 2ac19bef6a..b199dd1b39 100644 --- a/tests/Query/SearchInfo.test.ts +++ b/tests/Query/SearchInfo.test.ts @@ -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); @@ -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);