unit tests isAutoGeneratedPolicy
@@ -3,7 +3,9 @@ import {
getComplianceSteps,
complianceSteps,
getFieldIdentifierOption,
- getFieldIdentifierOptions
+ getFieldIdentifierOptions,
+ isAutoGeneratedPolicy,
+ PurgePolicy
} from 'wherehows-web/constants';
import complianceDataTypes from 'wherehows-web/mirage/fixtures/compliance-data-types';
@@ -50,3 +52,29 @@ test('getFieldIdentifierOptions function should behave as expected', function(as
assert.ok(result.value === complianceDataTypes[index].id, 'id matches the resulting value');
});
});
+
+test('isAutoGeneratedPolicy function correctly determines if a policy is auto-generated', function(assert) {
+ let result = isAutoGeneratedPolicy();
+
+ assert.ok(result === false, 'expected return value of false when no arguments are supplied');
+
+ result = isAutoGeneratedPolicy({
+ complianceType: PurgePolicy.AutoPurge,
+ complianceEntities: []
+ });
+
+ assert.ok(
+ result,
+ 'expected return to be truthy when complianceEntities are empty and complianceType is a PurgePolicy'
+ );
+
+ result = isAutoGeneratedPolicy({
+ complianceType: PurgePolicy.AutoPurge,
+ complianceEntities: [1]
+ });
+
+ assert.notOk(
+ result,
+ 'expected return to be falsey when complianceEntities are not empty and complianceType is a PurgePolicy'
+ );
+});
