@contrail/flexplm 1.1.60 → 1.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -234,4 +234,36 @@ describe('ThumbnailUtil Tests', () =>{
234
234
  expect(results).toBeTruthy();
235
235
  });
236
236
  });
237
+
238
+ describe('logContentResults', () =>{
239
+ it('no content - doesnt error', () =>{
240
+ const tu = new ThumbnailUtil(config);
241
+ const content = undefined;
242
+ const relations = [];
243
+ tu.logContentResults(content, relations);
244
+ });
245
+ it('no relations - doesnt error', () =>{
246
+ const tu = new ThumbnailUtil(config);
247
+ const content = undefined;
248
+ const relations = undefined;
249
+ tu.logContentResults(content, relations);
250
+ });
251
+
252
+ it('content and relations - logs', () =>{
253
+ const tu = new ThumbnailUtil(config);
254
+ const content = {
255
+ id: '123',
256
+ name: 'Test',
257
+ primaryFile: { id:'file123'}
258
+ };
259
+ const relations = ['primaryFile'];
260
+ tu.logContentResults(content, relations);
261
+
262
+ expect(Object.keys(content)).toHaveLength(3);
263
+ expect(content).toHaveProperty('primaryFile');
264
+ expect(content.primaryFile).toHaveProperty('id');
265
+ expect(content.primaryFile.id).toEqual('file123');
266
+ });
267
+
268
+ });
237
269
  });
@@ -105,17 +105,13 @@ export class ThumbnailUtil {
105
105
  }
106
106
 
107
107
  async getContentEntity(primaryViewableId: any, sizes: any[]) {
108
- const criteria = {
109
- id: primaryViewableId
110
- };
111
108
  const relations = sizes.map(s => s.slug);
112
109
  relations.push('primaryFile');
113
- const contentResults = await this.entities.get({
110
+ const content = await this.entities.get({
114
111
  entityName: 'content',
115
- criteria,
112
+ id: primaryViewableId,
116
113
  relations
117
114
  });
118
- const content = (contentResults && contentResults[0]) ? contentResults[0] : undefined;
119
115
  this.logContentResults(content, relations);
120
116
  return content;
121
117
  }
@@ -129,7 +125,7 @@ export class ThumbnailUtil {
129
125
  * @param relations: string[] of the slugs for inflated objects
130
126
  */
131
127
  logContentResults(content: any, relations: string[]) {
132
- if(Logger.isDebugOn()){
128
+ if(Logger.isDebugOn() && content && relations){
133
129
  const contentCopy = JSON.parse(JSON.stringify(content));
134
130
  relations.forEach(r => {
135
131
  delete contentCopy[r];
@@ -1,20 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "program": "${workspaceFolder}\\lib\\index.js",
15
- "outFiles": [
16
- "${workspaceFolder}/**/*.js"
17
- ]
18
- }
19
- ]
20
- }