8000 Fix #20 - Fix nested tree relations + Unit test · Wikodit/js-data-jsonapi-light@53b89eb · GitHub
[go: up one dir, main page]

Skip to content

Commit 53b89eb

Browse files
committed
Fix #20 - Fix nested tree relations + Unit test
1 parent d00f550 commit 53b89eb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
},
5959
"dependencies": {
6060
"es6-promise": "^4.0.5",
61-
"js-data": ">=3.0.0-rc.7",
62-
"js-data-http": ">=3.0.0-rc.2"
61+
"js-data": ">=3.0.0",
62+
"js-data-http": ">=3.0.0"
6363
}
6464
}

test/unit/relations/nested.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import { store } from '../../ds';
33
import * as Resources from '../../resources'
44

5-
describe.skip('relations/nested', () => {
5+
describe('relations/nested', () => {
66
describe('when data are fetched, relations should persist and be assigned if data is there', () => {
77
const
88
CATEGORY_LENGTH = 4,
@@ -43,18 +43,18 @@ describe.skip('relations/nested', () => {
4343
});
4444

4545
it('should be able to ascend in the nested tree to first ancestor', () => {
46-
let category = store.get('Category', CATEGORIES_ASCENDING_PATH[CATEGORIES_ASCENDING_PATH.length - 1]);
47-
let i = CATEGORIES_ASCENDING_PATH.length - 1; while (i--) {
48-
expect(category.parentId).to.equal(CATEGORIES_ASCENDING_PATH[i]);
46+
let category = store.get('Category', CATEGORIES_ASCENDING_PATH[0]);
47+
for (let i = 0, l = CATEGORIES_ASCENDING_PATH.length - 1; i < l; i++) {
48+
expect(category.parentId).to.equal(CATEGORIES_ASCENDING_PATH[i + 1]);
4949
expect(category).to.have.property('parent');
5050
expect(category.parent).to.exist;
51-
expect(category.parent.id).to.equal(CATEGORIES_ASCENDING_PATH[i]);
52-
expect(category.parent.name).to.equal(CATEGORIES_NAME[CATEGORIES_ASCENDING_PATH[i]]);
51+
expect(category.parent.id).to.equal(CATEGORIES_ASCENDING_PATH[i + 1]);
52+
expect(category.parent.name).to.equal(CATEGORIES_NAME[CATEGORIES_ASCENDING_PATH[i + 1]]);
5353

5454
category = category.parent
5555
}
5656

57-
expect(category.parent).to.be.null;
57+
expect(category.parent).to.be.undefined;
5858
});
5959

6060
it('should correctly retain children', () => {

0 commit comments

Comments
 (0)
0