Skip to content

Commit

Permalink
[NAE-2023] Update URI attributes on frontend
Browse files Browse the repository at this point in the history
- updated tests
  • Loading branch information
renczesstefan committed Dec 16, 2024
1 parent f4d6230 commit 5d6a049
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('UriService', () => {

it('should get root node', () => {
const root = service.root;
expect(root.id).toEqual('root');
expect(root.path).toEqual('root');
expect(service.isRoot(root)).toBeTruthy();
expect(service.activeNode).toEqual(root);
});
Expand All @@ -59,8 +59,7 @@ describe('UriService', () => {

it('should get node by path', done => {
service.getNodeByPath(MockUriResourceService.TEST1_PATH).subscribe(res => {
expect(res.uriPath).toEqual(MockUriResourceService.TEST1_PATH);
expect(res.id).toEqual(MockUriResourceService.TEST1_ID);
expect(res.path).toEqual(MockUriResourceService.TEST1_PATH);
done();
});
});
Expand All @@ -69,7 +68,7 @@ describe('UriService', () => {
service.getChildNodes(service.root).subscribe(res => {
expect(res.length).toEqual(2);
res.forEach(r => {
expect(r.id).toContain('test');
expect(r.path).toContain('test');
expect(r.parentId).toEqual('root');
});
done();
Expand All @@ -85,9 +84,9 @@ describe('UriService', () => {

it('should get siblings of a node', done => {
service.getNodeByPath(MockUriResourceService.TEST1_PATH).subscribe(node => {
expect(node.id).toEqual(MockUriResourceService.TEST1_ID);
expect(node.path).toEqual(MockUriResourceService.TEST1_PATH);
service.getSiblingsOfNode(node).subscribe(siblings => {
expect(siblings.find(n => n.id === MockUriResourceService.TEST2_ID)).not.toBeUndefined();
expect(siblings.find(n => n.path === MockUriResourceService.TEST2_PATH)).not.toBeUndefined();
done();
});
});
Expand All @@ -110,9 +109,7 @@ describe('UriService', () => {

it('should get parts of path', done => {
service.getNodeByPath(MockUriResourceService.TEST1_PATH).subscribe(node => {
const path = service.splitNodePath(node);
expect(path.length).toEqual(1);
expect(path[0]).toEqual(MockUriResourceService.TEST1_ID);
expect(node.path).toEqual(MockUriResourceService.TEST1_PATH);
done();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,22 @@ import {ResourceProvider} from '../../../resources/resource-provider.service';
@Injectable()
export class MockUriResourceService extends UriResourceService {

static TEST1_ID = 'test1';
static TEST1_PATH = 'root/test1';
static TEST2_ID = 'test2';
static TEST2_PATH = 'root/test2';

private _root: UriNodeResource = {
id: 'root',
uriPath: 'root',
path: 'root',
name: 'root',
parentId: null,
parent: undefined,
childrenId: new Set<string>([MockUriResourceService.TEST1_ID, MockUriResourceService.TEST2_ID]),
childrenId: new Set<string>([MockUriResourceService.TEST1_PATH, MockUriResourceService.TEST2_PATH]),
children: undefined,
level: 0,
contentTypes: undefined,
} as UriNodeResource;
private _test1Node: UriNodeResource = {
id: MockUriResourceService.TEST1_ID,
uriPath: MockUriResourceService.TEST1_PATH,
name: MockUriResourceService.TEST1_ID,
path: MockUriResourceService.TEST1_PATH,
name: MockUriResourceService.TEST1_PATH,
parentId: 'root',
parent: this._root,
childrenId: undefined,
Expand All @@ -36,9 +32,8 @@ export class MockUriResourceService extends UriResourceService {
contentTypes: new Set<UriContentType>([UriContentType.PROCESS]),
} as UriNodeResource;
private _test2Node: UriNodeResource = {
id: MockUriResourceService.TEST2_ID,
uriPath: MockUriResourceService.TEST2_PATH,
name: MockUriResourceService.TEST2_ID,
path: MockUriResourceService.TEST2_PATH,
name: MockUriResourceService.TEST2_PATH,
parentId: 'root',
parent: this._root,
childrenId: undefined,
Expand Down

0 comments on commit 5d6a049

Please sign in to comment.