Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/app/services/pathService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('PathService', () => {
service = TestBed.inject(PathService);
});
consolidatePaths();
arePathsEmpty();
});

function consolidatePaths() {
Expand All @@ -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();
});
});
}
13 changes: 2 additions & 11 deletions src/assets/wise5/services/pathService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down