Test 'trackBy' property in cluster template object

This change tests that the generated trackBy property contains the
expected value composed by the object id and updated_at when available
otherwise fallback to created_at.

Change-Id: I7becdd513cd17879d1c99c7b60ed708bb5a34a09
This commit is contained in:
Felipe Reyes 2023-12-06 18:57:33 -03:00
parent 9d1365ee18
commit 85290621fb
1 changed files with 7 additions and 1 deletions

View File

@ -31,12 +31,18 @@
var result = service.getClusterTemplatesPromise({});
deferred.resolve({
data:{
items: [{id: 123, name: 'template1'}]
items: [
{id: 123, name: 'template1', updated_at: '2020-01-01'},
{id: 456, name: 'template2', created_at: '2021-12-12'},
]
}
});
$timeout.flush();
expect(magnum.getClusterTemplates).toHaveBeenCalled();
expect(result.$$state.value.data.items[0].name).toBe('template1');
expect(result.$$state.value.data.items[0].trackBy).toBe('1232020-01-01');
expect(result.$$state.value.data.items[1].name).toBe('template2');
expect(result.$$state.value.data.items[1].trackBy).toBe('4562021-12-12');
}));
});