agilite
Advanced tools
Comparing version 6.5.0 to 6.6.0
@@ -54,5 +54,10 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -72,5 +77,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -90,5 +100,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -108,5 +123,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -113,0 +133,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -54,6 +54,14 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
config.headers[Enums.HEADER_CURRENT_USER] = currentUser | ||
if (processKey !== undefined && processKey !== null) { | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
} | ||
if (currentUser !== undefined && currentUser !== null) { | ||
config.headers[Enums.HEADER_CURRENT_USER] = currentUser | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -75,9 +83,27 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_APPLICATION_JSON | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
config.headers[Enums.HEADER_BPM_RECORD_ID] = bpmRecordId | ||
config.headers[Enums.HEADER_OPTION_SELECTED] = optionSelected | ||
config.headers[Enums.HEADER_CURRENT_USER] = currentUser | ||
config.headers[Enums.HEADER_COMMENTS] = comments | ||
if (processKey !== undefined && processKey !== null) { | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
} | ||
if (bpmRecordId !== undefined && bpmRecordId !== null) { | ||
config.headers[Enums.HEADER_BPM_RECORD_ID] = bpmRecordId | ||
} | ||
if (optionSelected !== undefined && optionSelected !== null) { | ||
config.headers[Enums.HEADER_OPTION_SELECTED] = optionSelected | ||
} | ||
if (currentUser !== undefined && currentUser !== null) { | ||
config.headers[Enums.HEADER_CURRENT_USER] = currentUser | ||
} | ||
if (comments !== undefined && comments !== null) { | ||
config.headers[Enums.HEADER_COMMENTS] = comments | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -96,14 +122,39 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
} | ||
if (processKeys !== undefined && processKeys !== null) { | ||
config.headers[Enums.HEADER_PROCESS_KEYS] = processKeys.join(Enums.SEPARATOR_COMMA) | ||
} | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (bpmRecordIds !== undefined && bpmRecordIds !== null) { | ||
config.headers[Enums.HEADER_BPM_RECORD_IDS] = bpmRecordIds.join(Enums.SEPARATOR_COMMA) | ||
} | ||
config.headers[Enums.HEADER_PROCESS_KEYS] = processKeys.join(Enums.SEPARATOR_COMMA) | ||
config.headers[Enums.HEADER_BPM_RECORD_IDS] = bpmRecordIds.join(Enums.SEPARATOR_COMMA) | ||
config.headers[Enums.HEADER_STEP_NAMES] = stepNames.join(Enums.SEPARATOR_COMMA) | ||
config.headers[Enums.HEADER_RESPONSIBLE_USERS] = responsibleUsers.join(Enums.SEPARATOR_COMMA) | ||
config.headers[Enums.HEADER_RELEVANT_USERS] = relevantUsers.join(Enums.SEPARATOR_COMMA) | ||
config.headers[Enums.HEADER_INCLUDE_HISTORY] = includeHistory | ||
config.headers[Enums.HEADER_INCLUDE_STEP_OPTIONS] = includeStepOptions | ||
config.headers[Enums.HEADER_INCLUDE_VISIBLE_OBJECTS] = includeVisibleObjects | ||
if (stepNames !== undefined && stepNames !== null) { | ||
config.headers[Enums.HEADER_STEP_NAMES] = stepNames.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (responsibleUsers !== undefined && responsibleUsers !== null) { | ||
config.headers[Enums.HEADER_RESPONSIBLE_USERS] = responsibleUsers.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (relevantUsers !== undefined && relevantUsers !== null) { | ||
config.headers[Enums.HEADER_RELEVANT_USERS] = relevantUsers.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (includeHistory !== undefined && includeHistory !== null) { | ||
config.headers[Enums.HEADER_INCLUDE_HISTORY] = includeHistory | ||
} | ||
if (includeStepOptions !== undefined && includeStepOptions !== null) { | ||
config.headers[Enums.HEADER_INCLUDE_STEP_OPTIONS] = includeStepOptions | ||
} | ||
if (includeVisibleObjects !== undefined && includeVisibleObjects !== null) { | ||
config.headers[Enums.HEADER_INCLUDE_VISIBLE_OBJECTS] = includeVisibleObjects | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -131,5 +182,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -149,5 +205,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -167,5 +228,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
if (processKey !== undefined && processKey !== null) { | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -185,5 +251,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
if (processKey !== undefined && processKey !== null) { | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -190,0 +261,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -56,8 +56,16 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_APPLICATION_JSON | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
config.headers[Enums.HEADER_ROUTE_KEY] = routeKey | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
if (routeKey !== undefined && routeKey !== null) { | ||
config.headers[Enums.HEADER_ROUTE_KEY] = routeKey | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -64,0 +72,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -55,6 +55,12 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_APPLICATION_JSON | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -61,0 +67,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -36,5 +36,10 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -55,4 +60,2 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (fileName && fileName !== '') { | ||
@@ -66,2 +69,6 @@ config.headers[Enums.HEADER_FILE_NAME] = fileName | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -81,5 +88,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -99,5 +111,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -104,0 +121,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -67,8 +67,18 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
if (sort !== undefined && sort !== null) { | ||
config.headers[Enums.HEADER_SORT] = sort | ||
} | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
config.headers[Enums.HEADER_SORT] = sort | ||
config.headers[Enums.HEADER_OUTPUT_FORMAT] = outputFormat | ||
if (outputFormat !== undefined && outputFormat !== null) { | ||
config.headers[Enums.HEADER_OUTPUT_FORMAT] = outputFormat | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -88,7 +98,14 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (groupName !== undefined && groupName !== null) { | ||
config.headers[Enums.HEADER_GROUP_NAME] = groupName | ||
} | ||
config.headers[Enums.HEADER_GROUP_NAME] = groupName | ||
config.headers[Enums.HEADER_SORT] = sort | ||
if (sort !== undefined && sort !== null) { | ||
config.headers[Enums.HEADER_SORT] = sort | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -108,8 +125,18 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
config.headers[Enums.HEADER_VALUE_KEY] = value | ||
config.headers[Enums.HEADER_OUTPUT_FORMAT] = outputFormat | ||
if (value !== undefined && value !== null) { | ||
config.headers[Enums.HEADER_VALUE_KEY] = value | ||
} | ||
if (outputFormat !== undefined && outputFormat !== null) { | ||
config.headers[Enums.HEADER_OUTPUT_FORMAT] = outputFormat | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -129,8 +156,18 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
config.headers[Enums.HEADER_LABEL_KEY] = label | ||
config.headers[Enums.HEADER_OUTPUT_FORMAT] = outputFormat | ||
if (label !== undefined && label !== null) { | ||
config.headers[Enums.HEADER_LABEL_KEY] = label | ||
} | ||
if (outputFormat !== undefined && outputFormat !== null) { | ||
config.headers[Enums.HEADER_OUTPUT_FORMAT] = outputFormat | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -137,0 +174,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -61,7 +61,15 @@ 'use strict' | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_APPLICATION_JSON | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
config.headers[Enums.HEADER_OUTPUT_FORMAT] = outputFormat | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
if (outputFormat !== undefined && outputFormat !== null) { | ||
config.headers[Enums.HEADER_OUTPUT_FORMAT] = outputFormat | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -81,5 +89,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -86,0 +99,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -56,7 +56,15 @@ 'use strict' | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_APPLICATION_JSON | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_ROLE_NAMES] = roleNames.join(Enums.SEPARATOR_COMMA) | ||
config.headers[Enums.HEADER_CONDITIONAL_LEVELS] = conditionalLevels.join(Enums.SEPARATOR_COMMA) | ||
if (roleNames !== undefined && roleNames !== null) { | ||
config.headers[Enums.HEADER_ROLE_NAMES] = roleNames.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (conditionalLevels !== undefined && conditionalLevels !== null) { | ||
config.headers[Enums.HEADER_CONDITIONAL_LEVELS] = conditionalLevels.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -76,10 +84,26 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (processKey !== undefined && processKey !== null) { | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
} | ||
if (bpmRecordId !== undefined && bpmRecordId !== null) { | ||
config.headers[Enums.HEADER_BPM_RECORD_ID] = bpmRecordId | ||
} | ||
if (roleName !== undefined && roleName !== null) { | ||
config.headers[Enums.HEADER_ROLE_NAME] = roleName | ||
} | ||
if (currentUser !== undefined && currentUser !== null) { | ||
config.headers[Enums.HEADER_CURRENT_USER] = currentUser | ||
} | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
config.headers[Enums.HEADER_BPM_RECORD_ID] = bpmRecordId | ||
config.headers[Enums.HEADER_ROLE_NAME] = roleName | ||
config.headers[Enums.HEADER_CURRENT_USER] = currentUser | ||
config.headers[Enums.HEADER_RESPONSIBLE_USERS] = responsibleUsers.join(Enums.SEPARATOR_COMMA) | ||
if (responsibleUsers !== undefined && responsibleUsers !== null) { | ||
config.headers[Enums.HEADER_RESPONSIBLE_USERS] = responsibleUsers.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -99,8 +123,18 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (processKey !== undefined && processKey !== null) { | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
} | ||
if (bpmRecordId !== undefined && bpmRecordId !== null) { | ||
config.headers[Enums.HEADER_BPM_RECORD_ID] = bpmRecordId | ||
} | ||
config.headers[Enums.HEADER_PROCESS_KEY] = processKey | ||
config.headers[Enums.HEADER_BPM_RECORD_ID] = bpmRecordId | ||
config.headers[Enums.HEADER_ROLE_NAMES] = roleNames.join(Enums.SEPARATOR_COMMA) | ||
if (roleNames !== undefined && roleNames !== null) { | ||
config.headers[Enums.HEADER_ROLE_NAMES] = roleNames.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -120,7 +154,14 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
config.headers[Enums.HEADER_CONDITIONAL_LEVELS] = conditionalLevels.join(Enums.SEPARATOR_COMMA) | ||
if (conditionalLevels !== undefined && conditionalLevels !== null) { | ||
config.headers[Enums.HEADER_CONDITIONAL_LEVELS] = conditionalLevels.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -139,7 +180,15 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
} | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
config.headers[Enums.HEADER_RESPONSIBLE_USER] = responsibleUser | ||
if (recordId !== undefined && recordId !== null) { | ||
config.headers[Enums.HEADER_RECORD_ID] = recordId | ||
} | ||
if (responsibleUser !== undefined && responsibleUser !== null) { | ||
config.headers[Enums.HEADER_RESPONSIBLE_USER] = responsibleUser | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -146,0 +195,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -55,7 +55,13 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_APPLICATION_JSON | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
if (profileKey !== undefined && profileKey !== null) { | ||
config.headers[Enums.HEADER_PROFILE_KEY] = profileKey | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -62,0 +68,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -67,11 +67,30 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (tierKeys !== undefined && tierKeys !== null) { | ||
config.headers[Enums.HEADER_TIER_KEYS] = tierKeys.join(Enums.SEPARATOR_COMMA) | ||
} | ||
if (includeValues !== undefined && includeValues !== null) { | ||
config.headers[Enums.HEADER_INCLUDE_VALUES] = includeValues | ||
} | ||
if (includeMetaData !== undefined && includeMetaData !== null) { | ||
config.headers[Enums.HEADER_INCLUDE_META_DATA] = includeMetaData | ||
} | ||
config.headers[Enums.HEADER_TIER_KEYS] = tierKeys.join(Enums.SEPARATOR_COMMA) | ||
config.headers[Enums.HEADER_INCLUDE_VALUES] = includeValues | ||
config.headers[Enums.HEADER_INCLUDE_META_DATA] = includeMetaData | ||
config.headers[Enums.HEADER_INCLUDE_TIER_ENTRIES] = includeTierEntries | ||
config.headers[Enums.HEADER_SORT_VALUES] = sortValues | ||
config.headers[Enums.HEADER_VALUES_OUTPUT_FORMAT] = valuesOutputFormat | ||
if (includeTierEntries !== undefined && includeTierEntries !== null) { | ||
config.headers[Enums.HEADER_INCLUDE_TIER_ENTRIES] = includeTierEntries | ||
} | ||
if (sortValues !== undefined && sortValues !== null) { | ||
config.headers[Enums.HEADER_SORT_VALUES] = sortValues | ||
} | ||
if (valuesOutputFormat !== undefined && valuesOutputFormat !== null) { | ||
config.headers[Enums.HEADER_VALUES_OUTPUT_FORMAT] = valuesOutputFormat | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -78,0 +97,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
@@ -36,5 +36,8 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_TEXT_PLAIN | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -55,5 +58,8 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_TEXT_PLAIN | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -74,5 +80,8 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_TEXT_PLAIN | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -93,5 +102,8 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_APPLICATION_JSON | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -112,5 +124,8 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_TEXT_PLAIN | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -131,5 +146,8 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_CONTENT_TYPE] = Enums.HEADER_APPLICATION_JSON | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -149,3 +167,5 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
@@ -166,7 +186,14 @@ if (this.teamId !== undefined && this.teamId !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (dateTimeValue !== undefined && dateTimeValue !== null) { | ||
config.headers[Enums.HEADER_DATE_TIME_VALUE] = dateTimeValue | ||
} | ||
config.headers[Enums.HEADER_DATE_TIME_VALUE] = dateTimeValue | ||
config.headers[Enums.HEADER_FORMAT_KEY] = formatKey | ||
if (formatKey !== undefined && formatKey !== null) { | ||
config.headers[Enums.HEADER_FORMAT_KEY] = formatKey | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -186,3 +213,5 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
@@ -203,7 +232,14 @@ if (this.teamId !== undefined && this.teamId !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
if (startDate !== undefined && startDate !== null) { | ||
config.headers[Enums.HEADER_START_DATE] = startDate | ||
} | ||
config.headers[Enums.HEADER_START_DATE] = startDate | ||
config.headers[Enums.HEADER_END_DATE] = endDate | ||
if (endDate !== undefined && endDate !== null) { | ||
config.headers[Enums.HEADER_END_DATE] = endDate | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -224,5 +260,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_INCLUDE_MODULES] = includeModules | ||
if (includeModules !== undefined && includeModules !== null) { | ||
config.headers[Enums.HEADER_INCLUDE_MODULES] = includeModules | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -242,5 +283,10 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
config.headers[Enums.HEADER_FILE_ID] = fileId | ||
if (fileId !== undefined && fileId !== null) { | ||
config.headers[Enums.HEADER_FILE_ID] = fileId | ||
} | ||
if (this.apiKey !== undefined && this.apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = this.apiKey | ||
} | ||
if (this.teamId !== undefined && this.teamId !== null) { | ||
@@ -247,0 +293,0 @@ config.headers[Enums.HEADER_TEAM_NAME] = this.teamId |
const data = { | ||
emptyObject: {}, | ||
emptyDataObject: { | ||
data: {} | ||
}, | ||
dataObject: { | ||
data: { | ||
name: '' | ||
} | ||
}, | ||
new: { | ||
@@ -3,0 +12,0 @@ data: { |
const data = { | ||
emptyObject: {}, | ||
emptyDataObject: { | ||
data: {} | ||
}, | ||
dataObject: { | ||
data: { | ||
name: '' | ||
} | ||
}, | ||
new: { | ||
@@ -3,0 +12,0 @@ data: { |
const data = { | ||
emptyObject: {}, | ||
emptyDataObject: { | ||
data: {} | ||
}, | ||
dataObject: { | ||
data: { | ||
name: '' | ||
} | ||
}, | ||
new: { | ||
@@ -3,0 +12,0 @@ data: { |
const data = { | ||
emptyObject: {}, | ||
emptyDataObject: { | ||
data: {} | ||
}, | ||
emptyValues: { | ||
data: { | ||
key: '', | ||
values: [] | ||
} | ||
}, | ||
invalidValues: { | ||
invalidObject: { | ||
data: { | ||
key: '', | ||
values: [""] | ||
} | ||
}, | ||
invalidLabel: { | ||
data: { | ||
key: '', | ||
values: [ | ||
{ | ||
labe: "label1", | ||
value: "value1" | ||
} | ||
] | ||
} | ||
}, | ||
invalidValue: { | ||
data: { | ||
key: '', | ||
values: [ | ||
{ | ||
label: "label1", | ||
valu: "value1" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
new: { | ||
@@ -3,0 +43,0 @@ data: { |
const data = { | ||
emptyObject: {}, | ||
emptyDataObject: { | ||
data: {} | ||
}, | ||
dataObject: { | ||
data: { | ||
name: '' | ||
} | ||
}, | ||
new: { | ||
@@ -3,0 +12,0 @@ data: { |
const data = { | ||
emptyObject: {}, | ||
emptyDataObject: { | ||
data: {} | ||
}, | ||
new: { | ||
@@ -3,0 +7,0 @@ data: { |
const data = { | ||
emptyObject: {}, | ||
emptyDataObject: { | ||
data: {} | ||
}, | ||
dataObject: { | ||
data: { | ||
name: '' | ||
} | ||
}, | ||
new: { | ||
@@ -10,3 +19,4 @@ data: { | ||
mode: 'plain_text', | ||
theme: 'monokai' | ||
theme: 'monokai', | ||
templateType: 'std' | ||
} | ||
@@ -22,3 +32,4 @@ }, | ||
mode: 'plain_text', | ||
theme: 'monokai' | ||
theme: 'monokai', | ||
templateType: 'std' | ||
} | ||
@@ -25,0 +36,0 @@ } |
const data = { | ||
emptyObject: {}, | ||
emptyDataObject: { | ||
data: {} | ||
}, | ||
emptyValues: { | ||
data: { | ||
key: '', | ||
values: [] | ||
} | ||
}, | ||
invalidValues: { | ||
invalidObject: { | ||
data: { | ||
key: '', | ||
values: [""] | ||
} | ||
}, | ||
invalidLabel: { | ||
data: { | ||
key: '', | ||
values: [ | ||
{ | ||
labe: "label1", | ||
value: "value1" | ||
} | ||
] | ||
} | ||
}, | ||
invalidValue: { | ||
data: { | ||
key: '', | ||
values: [ | ||
{ | ||
label: "label1", | ||
valu: "value1" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
new: { | ||
@@ -3,0 +43,0 @@ data: { |
{ | ||
"name": "agilite", | ||
"license": "MIT", | ||
"version": "6.5.0", | ||
"version": "6.6.0", | ||
"description": "A NodeJS module that provides seamless interactions with Agilit-e APIs", | ||
@@ -6,0 +6,0 @@ "homepage": "https://agilite.io", |
@@ -8,2 +8,3 @@ 'use strict' | ||
const Agilite = require('../controllers/agilite') | ||
const EnumsTypeDetect = require('../utils/enums-type-detect') | ||
const Enums = require('../utils/enums') | ||
@@ -23,4 +24,159 @@ const DataTemplate = require('../data-templates/keywords') | ||
let groupName = UUID.v1() | ||
let error = null | ||
it('Create New Record', (done) => { | ||
it('Create New Invalid Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Keywords.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Keywords.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No/Empty Values', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyValues)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("At least 1 'values' JSON entry is required") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - Invalid Values Array Entry', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidObject)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'label' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - Invalid Label Property', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidLabel)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'label' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - Invalid Value Property', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidValue)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'value' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Valid Record', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
@@ -31,3 +187,3 @@ mainEntry.data.key = key | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -55,3 +211,3 @@ // Check if GroupName exists and is blank | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -78,2 +234,208 @@ | ||
it('Update Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Keywords.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Keywords.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No/Empty Values', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyValues)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("At least 1 'values' JSON entry is required") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Invalid Values Array Entry', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidObject)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'label' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Invalid Label Property', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidLabel)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'label' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Invalid Value Property', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidValue)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'value' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Record ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.modified)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.putData(undefined, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Non-existant Record ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.modified)) | ||
mainEntry.data.key = key | ||
agilite.Keywords.putData("test", mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record', (done) => { | ||
@@ -89,3 +451,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -105,2 +467,48 @@ // Check if GroupName exists and contains passed value | ||
it('Get By Profile Key - No Profile Key', (done) => { | ||
agilite.Keywords.getByProfileKey(undefined) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Profile Key was specified in the 'profile-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get By Profile Key - Non-existant Profile Key', (done) => { | ||
agilite.Keywords.getByProfileKey("non-existant") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Active Keyword Profile cannot be found - non-existant") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get By Profile Key', (done) => { | ||
@@ -111,3 +519,3 @@ expect(key).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -127,2 +535,48 @@ expect(JSON.stringify(response.data)).to.equal(JSON.stringify(mainEntry.data.values)) | ||
it('Get Profile Keys by Group - No Group Name', (done) => { | ||
agilite.Keywords.getProfileKeysByGroup(undefined) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No value was specified in the 'group-name' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Profile Keys by Group - Non-existant Group Name', (done) => { | ||
agilite.Keywords.getProfileKeysByGroup("non-existant") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Active Keyword Profiles cannot be found for Group - non-existant") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Profile Keys by Group', (done) => { | ||
@@ -133,3 +587,3 @@ expect(groupName).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -144,6 +598,52 @@ expect(JSON.stringify(response.data)).to.equal(JSON.stringify([key])) | ||
it('Get Label By Value - No Value', (done) => { | ||
agilite.Keywords.getLabelByValue(key, undefined) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Value Key was specified in the 'value-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Label By Value - Non-existant Value', (done) => { | ||
agilite.Keywords.getLabelByValue(key, "non-existant") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Value Entry cannot be found - non-existant") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Label By Value', (done) => { | ||
agilite.Keywords.getLabelByValue(key, mainEntry.data.values[0].value) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_STRING_LOWER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.STRING) | ||
expect(response.data).to.equal(mainEntry.data.values[0].label) | ||
@@ -157,6 +657,52 @@ }) | ||
it('Get Value By Label - No Label', (done) => { | ||
agilite.Keywords.getValueByLabel(key, undefined) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Label Key was specified in the 'label-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Value By Label - Non-existant Label', (done) => { | ||
agilite.Keywords.getValueByLabel(key, "non-existant") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Label Entry cannot be found - non-existant") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Value By Label', (done) => { | ||
agilite.Keywords.getValueByLabel(key, mainEntry.data.values[0].label) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_STRING_LOWER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.STRING) | ||
expect(response.data).to.equal(mainEntry.data.values[0].value) | ||
@@ -170,2 +716,48 @@ }) | ||
it('Delete Record - No Record ID', (done) => { | ||
agilite.Keywords.deleteData() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record - Non-existant Record ID', (done) => { | ||
agilite.Keywords.deleteData("test") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record', (done) => { | ||
@@ -176,3 +768,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -179,0 +771,0 @@ }) |
@@ -8,3 +8,3 @@ 'use strict' | ||
const Agilite = require('../controllers/agilite') | ||
const Enums = require('../utils/enums') | ||
const EnumsTypeDetect = require('../utils/enums-type-detect') | ||
const DataTemplate = require('../data-templates/numbering') | ||
@@ -23,3 +23,80 @@ | ||
let groupName = UUID.v1() | ||
let error = null | ||
it('Create New Invalid Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Numbering.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Numbering.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Name', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.Numbering.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Record', (done) => { | ||
@@ -32,3 +109,3 @@ mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -61,3 +138,3 @@ // Check if Optional Fields exists | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -88,3 +165,3 @@ | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_NUMBER_LOWER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.NUMBER) | ||
expect(response.data).to.equal(1) | ||
@@ -98,2 +175,109 @@ }) | ||
it('Update Record - No ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Numbering.putData(undefined, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Empty Body Object', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Numbering.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Key', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Numbering.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Name', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.Numbering.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record', (done) => { | ||
@@ -110,3 +294,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -128,3 +312,3 @@ // Check if GroupName exists and contains passed value | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_STRING_LOWER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.STRING) | ||
expect(response.data).to.equal('PRE00010SUF') | ||
@@ -143,3 +327,3 @@ }) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_STRING_LOWER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.STRING) | ||
expect(response.data).to.equal('PRE00011SUF') | ||
@@ -158,3 +342,3 @@ }) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -173,3 +357,3 @@ }) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_STRING_LOWER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.STRING) | ||
expect(response.data).to.equal('PRE00010SUF') | ||
@@ -183,2 +367,48 @@ }) | ||
it('Delete Record - No Record ID', (done) => { | ||
agilite.Numbering.deleteData() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record - Non-existant Record ID', (done) => { | ||
agilite.Numbering.deleteData("test") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record', (done) => { | ||
@@ -189,3 +419,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -192,0 +422,0 @@ }) |
@@ -8,3 +8,3 @@ 'use strict' | ||
const Agilite = require('../controllers/agilite') | ||
const Enums = require('../utils/enums') | ||
const EnumsTypeDetect = require('../utils/enums-type-detect') | ||
const DataTemplate = require('../data-templates/connectors') | ||
@@ -23,3 +23,147 @@ | ||
let routeId = UUID.v1() | ||
let error = null | ||
let connectionTypes = ["1", "6", "10", "11", "12"] | ||
let connectionTypeLabels = ["webAPI", "imap", "mongodb", "ftp", "connectionData"] | ||
let tmpValue = null | ||
it('Create New Invalid Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Connectors.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Connectors.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Name', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.Connectors.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Connection Type', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.key = key | ||
mainEntry.data.name = key | ||
mainEntry.data.routes[0]._id = routeId | ||
// Remove Connection Type | ||
delete mainEntry.data.connectionType | ||
agilite.Connectors.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'connectionType'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
connectionTypeLabels.map((entry, index) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.key = key | ||
mainEntry.data.name = key | ||
mainEntry.data.routes[0]._id = routeId | ||
it(`Create New Invalid Record - No ${entry} Object`, (done) => { | ||
delete mainEntry.data[entry] | ||
mainEntry.data.connectionType = connectionTypes[index] | ||
agilite.Connectors.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal(`Please provide a valid '${entry}' property in the data object`) | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
}) | ||
it('Create New Record', (done) => { | ||
@@ -33,3 +177,3 @@ mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -55,3 +199,3 @@ // Compare values to confirm that data passed is the same as the data returned | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -77,2 +221,151 @@ | ||
it('Update Record - Empty Body Object', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Connectors.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Key', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Connectors.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Name', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.Connectors.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Connection Type', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.key = key | ||
mainEntry.data.name = key | ||
mainEntry.data.routes[0]._id = routeId | ||
// Remove Connection Type | ||
delete mainEntry.data.connectionType | ||
agilite.Connectors.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'connectionType'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
connectionTypeLabels.map((entry, index) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.key = key | ||
mainEntry.data.name = key | ||
mainEntry.data.routes[0]._id = routeId | ||
it(`Update Record - No ${entry} Object`, (done) => { | ||
delete mainEntry.data[entry] | ||
mainEntry.data.connectionType = connectionTypes[index] | ||
expect(recordId).to.not.equal(null) | ||
agilite.Connectors.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal(`Please provide a valid '${entry}' property in the data object`) | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
}) | ||
it('Update Record', (done) => { | ||
@@ -88,3 +381,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -101,2 +394,52 @@ // Compare Values object to confirm that data passed is the same as the data returned | ||
it('Execute - No Profile Key', (done) => { | ||
expect(key).to.not.equal(null) | ||
agilite.Connectors.execute(undefined, 'ping') | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Profile Key was specified in the 'profile-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Execute - No Route Key', (done) => { | ||
expect(key).to.not.equal(null) | ||
agilite.Connectors.execute(key, undefined) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Route Key was specified in the 'route-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Execute', (done) => { | ||
@@ -107,3 +450,3 @@ expect(key).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_STRING_LOWER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.STRING) | ||
expect(response.data).to.equal('Greetings from Agilit-e') | ||
@@ -117,2 +460,48 @@ }) | ||
it('Delete Record - No Record ID', (done) => { | ||
agilite.Connectors.deleteData() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record - Non-existant Record ID', (done) => { | ||
agilite.Connectors.deleteData("test") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record', (done) => { | ||
@@ -123,3 +512,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -126,0 +515,0 @@ }) |
@@ -8,3 +8,3 @@ 'use strict' | ||
const Agilite = require('../controllers/agilite') | ||
const Enums = require('../utils/enums') | ||
const EnumsTypeDetect = require('../utils/enums-type-detect') | ||
const DataTemplate = require('../data-templates/datamappings') | ||
@@ -22,3 +22,137 @@ | ||
let key = UUID.v1() | ||
let error = null | ||
it('Create New Invalid Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.DataMappings.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.DataMappings.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Name', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.DataMappings.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Source Type', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.key = key | ||
mainEntry.data.name = key | ||
delete mainEntry.data.sourceType | ||
agilite.DataMappings.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'sourceType'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Destination Type', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.key = key | ||
mainEntry.data.name = key | ||
delete mainEntry.data.destinationType | ||
agilite.DataMappings.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'destinationType'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Record', (done) => { | ||
@@ -31,3 +165,3 @@ mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -52,3 +186,3 @@ // Compare values to confirm that data passed is the same as the data returned | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -74,2 +208,171 @@ | ||
it('Update Record - Empty Body Object', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.DataMappings.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Key', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.DataMappings.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Name', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.DataMappings.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Source Type', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.key = key | ||
mainEntry.data.name = key | ||
delete mainEntry.data.sourceType | ||
agilite.DataMappings.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'sourceType'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Destination Type', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.key = key | ||
mainEntry.data.name = key | ||
delete mainEntry.data.destinationType | ||
agilite.DataMappings.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'destinationType'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Record ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.DataMappings.putData(undefined, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record', (done) => { | ||
@@ -85,3 +388,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -98,2 +401,25 @@ // Compare Values object to confirm that data passed is the same as the data returned | ||
it('Execute - No Key', (done) => { | ||
agilite.DataMappings.execute() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Profile Key was specified in the 'profile-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Execute', (done) => { | ||
@@ -104,3 +430,3 @@ expect(key).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
}) | ||
@@ -113,2 +439,48 @@ // .catch((err) => { | ||
it('Delete Record - No Record ID', (done) => { | ||
agilite.DataMappings.deleteData() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record - Non-existant Record ID', (done) => { | ||
agilite.DataMappings.deleteData("test") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record', (done) => { | ||
@@ -119,3 +491,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -122,0 +494,0 @@ }) |
@@ -8,3 +8,3 @@ 'use strict' | ||
const Agilite = require('../controllers/agilite') | ||
const Enums = require('../utils/enums') | ||
const EnumsTypeDetect = require('../utils/enums-type-detect'); | ||
const DataTemplate = require('../data-templates/templates') | ||
@@ -22,3 +22,80 @@ | ||
let key = UUID.v1() | ||
let error = null; | ||
it('Create New Invalid Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Templates.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Templates.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Template Type', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.Templates.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a 'templateType'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Record', (done) => { | ||
@@ -30,3 +107,3 @@ mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -50,3 +127,3 @@ // Compare values to confirm that data passed is the same as the data returned | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -72,2 +149,109 @@ | ||
it('Update Record - Empty Body Object', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Templates.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Key', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Templates.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Template Type', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.Templates.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a 'templateType'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Record ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Templates.putData(undefined, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record', (done) => { | ||
@@ -82,3 +266,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -94,2 +278,25 @@ // Compare Values object to confirm that data passed is the same as the data returned | ||
it('Execute - No Key', (done) => { | ||
agilite.Templates.execute() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Profile Key was specified in the 'profile-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Execute', (done) => { | ||
@@ -100,3 +307,3 @@ expect(key).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_STRING_LOWER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.STRING) | ||
}) | ||
@@ -109,2 +316,48 @@ // .catch((err) => { | ||
it('Delete Record - No Record ID', (done) => { | ||
agilite.Templates.deleteData() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record - Non-existant Record ID', (done) => { | ||
agilite.Templates.deleteData("test") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record', (done) => { | ||
@@ -115,3 +368,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -118,0 +371,0 @@ }) |
@@ -8,3 +8,3 @@ 'use strict' | ||
const Agilite = require('../controllers/agilite') | ||
const Enums = require('../utils/enums') | ||
const EnumsTypeDetect = require('../utils/enums-type-detect') | ||
const DataTemplate = require('../data-templates/bpm') | ||
@@ -26,3 +26,80 @@ | ||
let optionId = UUID.v1() | ||
let error = null | ||
it('Create New Invalid Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.BPM.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.BPM.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Name', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.BPM.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Record', (done) => { | ||
@@ -35,3 +112,3 @@ mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -66,3 +143,3 @@ // Check if Optional Fields exists | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -88,2 +165,109 @@ | ||
it('Update Record - No ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.BPM.putData(undefined, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Empty Body Object', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.BPM.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Key', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.BPM.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Name', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.dataObject)) | ||
mainEntry.data.key = key | ||
agilite.BPM.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record', (done) => { | ||
@@ -101,3 +285,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -115,6 +299,29 @@ // Check if pre-defined exists and contains passed value | ||
it('Get Record State - No Headers', (done) => { | ||
agilite.BPM.getRecordState() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("At least one header property of ('process-keys', 'bpm-record-ids', 'step-names') or ('responsible-users', 'relevant-users') needs to be provided") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Record State - 1', (done) => { | ||
agilite.BPM.getRecordState([key]) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.equal(0) | ||
@@ -128,6 +335,29 @@ }) | ||
it('Get Active Steps - No Headers', (done) => { | ||
agilite.BPM.getActiveSteps() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Process Key was specified in the 'process-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Active Steps - 1', (done) => { | ||
agilite.BPM.getActiveSteps(key) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.equal(0) | ||
@@ -141,6 +371,29 @@ }) | ||
it('Get Active Users - No Headers', (done) => { | ||
agilite.BPM.getActiveUsers() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Process Key was specified in the 'process-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Active Users - 1', (done) => { | ||
agilite.BPM.getActiveUsers(key) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.equal(0) | ||
@@ -154,6 +407,29 @@ }) | ||
it('Register BPM Record - No Headers', (done) => { | ||
agilite.BPM.registerBPMRecord() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Process Key was specified in the 'process-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Register BPM Record', (done) => { | ||
agilite.BPM.registerBPMRecord(key, 'user.current@acme.com') | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -198,3 +474,3 @@ tmpEntry = response.data | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -226,3 +502,3 @@ tmpEntry = response.data | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.equal(1) | ||
@@ -269,3 +545,3 @@ | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.equal(1) | ||
@@ -282,3 +558,3 @@ }) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.equal(1) | ||
@@ -295,3 +571,3 @@ }) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -330,3 +606,3 @@ tmpEntry = response.data | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.equal(1) | ||
@@ -348,3 +624,3 @@ | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
}) | ||
@@ -357,2 +633,48 @@ // .catch((err) => { | ||
it('Delete Record - No Record ID', (done) => { | ||
agilite.BPM.deleteData() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record - Non-existant Record ID', (done) => { | ||
agilite.BPM.deleteData("test") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record', (done) => { | ||
@@ -363,3 +685,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -366,0 +688,0 @@ }) |
@@ -8,3 +8,3 @@ 'use strict' | ||
const Agilite = require('../controllers/agilite') | ||
const Enums = require('../utils/enums') | ||
const EnumsTypeDetect = require('../utils/enums-type-detect') | ||
const DataTemplate = require('../data-templates/roles') | ||
@@ -21,3 +21,2 @@ | ||
let recordId = null | ||
let key = UUID.v1() | ||
let groupName = UUID.v1() | ||
@@ -27,10 +26,61 @@ let processKey = UUID.v1() | ||
let roleName = UUID.v1() | ||
let error = null | ||
it('Create New Invalid Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Roles.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Name', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Roles.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a Role 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Record', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
mainEntry.data.name = key | ||
mainEntry.data.name = roleName | ||
agilite.Roles.postData(mainEntry) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -63,3 +113,3 @@ // Check if Optional Fields exists | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -85,8 +135,86 @@ | ||
it('Update Record - No ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Roles.putData(undefined, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Empty Body Object', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.Roles.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Name', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.Roles.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a Role 'name'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record', (done) => { | ||
expect(recordId).to.not.equal(null) | ||
key = 'PUT_' + key | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.modified1)) | ||
mainEntry.data.name = key | ||
mainEntry.data.name = roleName | ||
mainEntry.data.groupName = groupName | ||
@@ -96,3 +224,3 @@ | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -114,3 +242,3 @@ // Check if GroupName exists and contains passed value | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -124,6 +252,29 @@ }) | ||
it('Assign Role - No Required Data', (done) => { | ||
agilite.Roles.assignRole() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No BPM Process Key was specified in the 'process-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Assign Role', (done) => { | ||
agilite.Roles.assignRole(processKey, bpmRecordId, roleName, 'roles.current@acme.com', ['roles.resp1@acme.com', 'roles.resp2@acme.com']) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(response.data).to.haveOwnProperty('hasChanged') | ||
@@ -142,6 +293,29 @@ expect(response.data).to.haveOwnProperty('id') | ||
it('Get Assigned Roles - No Headers', (done) => { | ||
agilite.Roles.getAssignedRoles() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No BPM Process Key was specified in the 'process-key' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Assigned Roles', (done) => { | ||
agilite.Roles.getAssignedRoles(processKey, bpmRecordId, [roleName]) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.equal(1) | ||
@@ -160,6 +334,29 @@ | ||
it('Get Role - No Headers', (done) => { | ||
agilite.Roles.getRole() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Role Name(s) were specified in the 'role-names' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Role', (done) => { | ||
agilite.Roles.getRole([roleName], [processKey, bpmRecordId]) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -177,6 +374,29 @@ expect(response.data).to.haveOwnProperty('roleIds') | ||
it('Change Conditional Levels - No Record ID', (done) => { | ||
agilite.Roles.changeConditionalLevels() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Change Conditional Levels', (done) => { | ||
agilite.Roles.changeConditionalLevels(recordId, [bpmRecordId]) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.be.equal('{}') | ||
@@ -190,6 +410,29 @@ }) | ||
it('Re-Assign Responsible Person - No Responsible User header', (done) => { | ||
agilite.Roles.reAssignResponsibleUser() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No User was specified in the 'responsible-user' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Re-Assign Responsible Person', (done) => { | ||
agilite.Roles.reAssignResponsibleUser(recordId, 'roles.resp3@acme.com') | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.be.equal('{}') | ||
@@ -206,3 +449,3 @@ }) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -221,2 +464,48 @@ expect(response.data).to.haveOwnProperty('roleIds') | ||
it('Delete Assigned Role Record - No Record ID', (done) => { | ||
agilite.Roles.deleteData() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Assigned Role Record - Non-existant Record ID', (done) => { | ||
agilite.Roles.deleteData("test") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Assigned Role Record', (done) => { | ||
@@ -227,3 +516,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -230,0 +519,0 @@ }) |
@@ -8,3 +8,3 @@ 'use strict' | ||
const Agilite = require('../controllers/agilite') | ||
const Enums = require('../utils/enums') | ||
const EnumsTypeDetect = require('../utils/enums-type-detect') | ||
const DataTemplate = require('../data-templates/tierstructures') | ||
@@ -22,3 +22,132 @@ | ||
let key = UUID.v1() | ||
let error = null | ||
it('Create New Invalid Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.TierStructures.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.TierStructures.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - Invalid Values Array Entry', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidObject)) | ||
mainEntry.data.key = key | ||
agilite.TierStructures.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'label' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - Invalid Label Property', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidLabel)) | ||
mainEntry.data.key = key | ||
agilite.TierStructures.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'label' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Invalid Record - Invalid Value Property', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidValue)) | ||
mainEntry.data.key = key | ||
agilite.TierStructures.postData(mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'value' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Create New Record', (done) => { | ||
@@ -30,3 +159,3 @@ mainEntry = JSON.parse(JSON.stringify(DataTemplate.new)) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -57,3 +186,3 @@ // Check if Optional Fields exists | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -79,2 +208,182 @@ | ||
it('Update Record - Empty Body Object', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyObject)) | ||
agilite.TierStructures.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No 'data' property found in JSON Body") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Key', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.emptyDataObject)) | ||
agilite.TierStructures.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid Profile 'key'") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Invalid Values Array Entry', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidObject)) | ||
mainEntry.data.key = key | ||
agilite.TierStructures.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'label' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Invalid Label Property', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidLabel)) | ||
mainEntry.data.key = key | ||
agilite.TierStructures.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'label' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Invalid Value Property', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.invalidValues.invalidValue)) | ||
mainEntry.data.key = key | ||
agilite.TierStructures.putData(recordId, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Please provide a valid 'value' property in the 'values' entry") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - No Record ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.modified)) | ||
mainEntry.data.key = key | ||
agilite.TierStructures.putData(undefined, mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record - Non-existant Record ID', (done) => { | ||
mainEntry = JSON.parse(JSON.stringify(DataTemplate.modified)) | ||
mainEntry.data.key = key | ||
agilite.TierStructures.putData("test", mainEntry) | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Update Record', (done) => { | ||
@@ -89,3 +398,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
@@ -101,6 +410,29 @@ // Check if Tier Entries has more than 1 value | ||
it('Get Tier By Key - No Headers', (done) => { | ||
agilite.TierStructures.getTierByKey() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Tier Keys were specified in the 'tier-keys' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Get Tier By Key - Tier 1', (done) => { | ||
agilite.TierStructures.getTierByKey([key], true, false, false, agilite.TierStructures.sort.ASC, agilite.TierStructures.outputFormat.ARRAY) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_ARRAY_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.ARRAY) | ||
expect(response.data.length).to.be.greaterThan(0) | ||
@@ -114,2 +446,48 @@ }) | ||
it('Delete Record - No Record ID', (done) => { | ||
agilite.TierStructures.deleteData() | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("No Id was specified in the 'record-id' header parameter") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record - Non-existant Record ID', (done) => { | ||
agilite.TierStructures.deleteData("test") | ||
.then((response) => {}) | ||
.catch((err) => { | ||
error = err.response.data | ||
expect(TypeDetect(error)).to.equal(EnumsTypeDetect.OBJECT) | ||
// Check if statusCode exists and contains correct value | ||
expect(error).to.haveOwnProperty('statusCode') | ||
expect(error.statusCode).to.equal(400) | ||
// Check if errorMessage exists and contains correct error message | ||
expect(error).to.haveOwnProperty('errorMessage') | ||
expect(error.errorMessage).to.equal("Record with id: 'test' cannot be found") | ||
// Check if additionalMessages exists and is blank array | ||
expect(error).to.haveOwnProperty('additionalMessages') | ||
expect(TypeDetect(error.additionalMessages)).to.equal(EnumsTypeDetect.ARRAY) | ||
}) | ||
.then(done, done) | ||
}) | ||
it('Delete Record', (done) => { | ||
@@ -120,3 +498,3 @@ expect(recordId).to.not.equal(null) | ||
.then((response) => { | ||
expect(TypeDetect(response.data)).to.equal(Enums.VALUE_OBJECT_PROPER) | ||
expect(TypeDetect(response.data)).to.equal(EnumsTypeDetect.OBJECT) | ||
expect(JSON.stringify(response.data)).to.equal('{}') | ||
@@ -123,0 +501,0 @@ }) |
@@ -18,3 +18,5 @@ 'use strict' | ||
config.headers[Enums.HEADER_API_KEY] = apiKey | ||
if(apiKey !== undefined && apiKey !== null) { | ||
config.headers[Enums.HEADER_API_KEY] = apiKey | ||
} | ||
@@ -21,0 +23,0 @@ if (teamId !== undefined && teamId !== null) { |
235445
37
5463