Skip to content

Commit

Permalink
test: use ondDeep instead of traversing level by level
Browse files Browse the repository at this point in the history
  • Loading branch information
vedkribhu committed Oct 17, 2023
1 parent 40ec5c2 commit 343661d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions test/unit/item.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,23 @@ describe('Item', function () {
describe('.getPath()', function () {
it('should return correct path for 2 level nested item', function () {
const collection = new sdk.Collection(fixtures.nestedCollectionV2),
f1 = collection.items.members[0],
r1 = f1.items.members[0];
req = collection.oneDeep('F1.R1');

expect(r1.getPath()).to.deep.equal(['multi-level-folders-v2', 'F1', 'F1.R1']);
expect(req.getPath()).to.deep.equal(['multi-level-folders-v2', 'F1', 'F1.R1']);
});

it('should return correct path for 1 level nested item', function () {
const collection = new sdk.Collection(fixtures.nestedCollectionV2),
r1 = collection.items.members[2];
req = collection.oneDeep('R1');

expect(r1.getPath()).to.deep.equal(['multi-level-folders-v2', 'R1']);
expect(req.getPath()).to.deep.equal(['multi-level-folders-v2', 'R1']);
});

it('should return correct path for 3 level nested item', function () {
const collection = new sdk.Collection(fixtures.nestedCollectionV2),
f2 = collection.items.members[1],
f3 = f2.items.members[0],
r1 = f3.items.members[0];
req = collection.oneDeep('F2.F3.R1');

expect(r1.getPath()).to.deep.equal(['multi-level-folders-v2', 'F2', 'F2.F3', 'F2.F3.R1']);
expect(req.getPath()).to.deep.equal(['multi-level-folders-v2', 'F2', 'F2.F3', 'F2.F3.R1']);
});

it('should return path as empty array for item without name', function () {
Expand Down

0 comments on commit 343661d

Please sign in to comment.