diff --git a/src/app/services/pathService.spec.ts b/src/app/services/pathService.spec.ts index 6c19fec600c..86e69e859ec 100644 --- a/src/app/services/pathService.spec.ts +++ b/src/app/services/pathService.spec.ts @@ -11,6 +11,7 @@ describe('PathService', () => { service = TestBed.inject(PathService); }); consolidatePaths(); + arePathsEmpty(); }); function consolidatePaths() { @@ -35,3 +36,12 @@ function consolidatePaths() { }); }); } + +function arePathsEmpty() { + describe('arePathsEmpty()', () => { + it('should return true iff all paths are empty', () => { + expect(service.arePathsEmpty([[], []])).toBeTrue(); + expect(service.arePathsEmpty([['node1'], []])).toBeFalse(); + }); + }); +} diff --git a/src/assets/wise5/services/pathService.ts b/src/assets/wise5/services/pathService.ts index be28a13197a..987f63022c3 100644 --- a/src/assets/wise5/services/pathService.ts +++ b/src/assets/wise5/services/pathService.ts @@ -5,19 +5,10 @@ export class PathService { /** * Check if all the paths are empty * @param paths an array of paths. each path is an array of node ids - * @return whether all the paths are empty + * @return true iff all the paths are empty */ arePathsEmpty(paths: string[][]): boolean { - if (paths != null) { - for (let path of paths) { - if (path != null) { - if (path.length !== 0) { - return false; - } - } - } - } - return true; + return paths.every((path) => path.length === 0); } /**