Fixed multi credential service unit test failures

Signed-off-by: mabashian <mabashia@redhat.com>
This commit is contained in:
mabashian 2017-09-14 09:14:27 -04:00
parent f90771ee1a
commit 549737405b
No known key found for this signature in database
GPG Key ID: 436B8D5EDC704CE3
2 changed files with 77 additions and 3 deletions

View File

@ -138,7 +138,7 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
name: cred.name,
id: cred.id,
postType: cred.postType,
readOnly: cred.readOnly,
readOnly: cred.readOnly ? true : false,
kind: typeOpts
.filter(type => {
return parseInt(cred.credential_type) === type.value;

View File

@ -1,4 +1,4 @@
'use strict'
'use strict';
describe('MultiCredentialService', () => {
let MultiCredentialService;
@ -79,7 +79,7 @@ describe('MultiCredentialService', () => {
expect(equal).toBe(true);
});
it('should return array of selected credentials (populated)', () => {
it('should return array of selected credentials (populated, not read only)', () => {
let creds = {
machine: {
credential_type: 1,
@ -120,18 +120,92 @@ describe('MultiCredentialService', () => {
name: 'ssh',
id: 3,
postType: 'machine',
readOnly: false,
kind: 'SSH:'
},
{
name: 'aws',
id: 4,
postType: 'extra',
readOnly: false,
kind: 'Amazon Web Services:'
},
{
name: 'gce',
id: 5,
postType: 'extra',
readOnly: false,
kind: 'Google Compute Engine:'
}
];
let actual = MultiCredentialService
.updateCredentialTags(creds, typeOpts);
let equal = _.isEqual(expected.sort(), actual.sort());
expect(equal).toBe(true);
});
it('should return array of selected credentials (populated, read only)', () => {
let creds = {
machine: {
credential_type: 1,
id: 3,
name: 'ssh',
readOnly: true
},
extra: [
{
credential_type: 2,
id: 4,
name: 'aws',
readOnly: true
},
{
credential_type: 3,
id: 5,
name: 'gce',
readOnly: true
}
]
};
let typeOpts = [
{
name: 'SSH',
value: 1
},
{
name: 'Amazon Web Services',
value: 2
},
{
name: 'Google Compute Engine',
value: 3
}
];
let expected = [
{
name: 'ssh',
id: 3,
postType: 'machine',
readOnly: true,
kind: 'SSH:'
},
{
name: 'aws',
id: 4,
postType: 'extra',
readOnly: true,
kind: 'Amazon Web Services:'
},
{
name: 'gce',
id: 5,
postType: 'extra',
readOnly: true,
kind: 'Google Compute Engine:'
}
];