Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should change display name every time node changes', fakeAsync(() => {
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValues(
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } })),
Promise.resolve(new NodeEntry({ entry: { name: 'file2', content: {} } }))
);
component.urlFile = null;
component.displayName = null;
component.blobFile = null;
component.showViewer = true;
component.nodeId = 'id1';
component.ngOnChanges();
tick();
expect(component.fileTitle).toBe('file1');
component.nodeId = 'id2';
component.ngOnChanges();
tick();
describe('display name property override by nodeId', () => {
const displayName = 'the-name';
const nodeDetails = new NodeEntry({ entry: { name: displayName, id: '12', content: { mimeType: 'txt' } } });
const contentUrl = '/content/url/path';
const alfrescoApiInstanceMock = {
nodes: {
getNode: () => Promise.resolve(nodeDetails)
},
content: { getContentUrl: () => contentUrl }
};
it('should use the node name if displayName is NOT set and nodeId is set', (done) => {
component.nodeId = '12';
component.urlFile = null;
component.displayName = null;
spyOn(alfrescoApiService, 'getInstance').and.returnValue(alfrescoApiInstanceMock);
component.ngOnChanges();
fixture.whenStable().then(() => {
it('should get and assign node for download', (done) => {
component.nodeId = '12';
component.urlFile = '';
const displayName = 'the-name';
const node = new NodeEntry({ entry: { name: displayName, id: '12', content: { mimeType: 'txt' } } });
const nodeDetails = { name: displayName, id: '12', content: { mimeType: 'txt' } };
const contentUrl = '/content/url/path';
const alfrescoApiInstanceMock = {
nodes: {
getNodeInfo: () => Promise.resolve(nodeDetails),
getNode: () => Promise.resolve(node)
},
content: { getContentUrl: () => contentUrl }
};
spyOn(alfrescoApiService, 'getInstance').and.returnValue(alfrescoApiInstanceMock);
component.ngOnChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(component.nodeEntry).toBe(node);
done();
constructor(nodeEntry: NodeEntry, level?: number, expandable?: boolean) {
this.name = nodeEntry.entry.name;
this.nodeId = nodeEntry.entry.id;
this.level = level ? level : 0;
this.expandable = expandable ? expandable : true;
this.node = nodeEntry ? new NodeEntry(nodeEntry) : undefined;
}
}