2017-10-02 18:49:35 -07:00
|
|
|
import {
|
|
|
|
createInitialComplianceInfo,
|
2017-10-07 17:49:57 -07:00
|
|
|
fieldChangeSetRequiresReview,
|
|
|
|
isRecentSuggestion
|
2017-10-02 18:49:35 -07:00
|
|
|
} from 'wherehows-web/utils/datasets/compliance-policy';
|
|
|
|
|
|
|
|
import { mockFieldChangeSets } from 'wherehows-web/tests/helpers/datasets/compliance-policy/field-changeset-constants';
|
2017-10-07 17:49:57 -07:00
|
|
|
import { mockTimeStamps } from 'wherehows-web/tests/helpers/datasets/compliance-policy/recent-suggestions-constants';
|
2017-10-02 18:49:35 -07:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
|
|
|
module('Unit | Utility | datasets/compliance policy');
|
|
|
|
|
|
|
|
test('Utility function createInitialComplianceInfo exists', function(assert) {
|
|
|
|
assert.expect(2);
|
|
|
|
const mockId = 1337;
|
|
|
|
const initialComplianceInfo = {
|
|
|
|
datasetId: mockId,
|
2017-10-20 21:57:40 -07:00
|
|
|
complianceType: '',
|
|
|
|
compliancePurgeNote: '',
|
2017-10-02 18:49:35 -07:00
|
|
|
complianceEntities: [],
|
2017-10-20 21:57:40 -07:00
|
|
|
datasetClassification: {}
|
2017-10-02 18:49:35 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
assert.ok(typeof createInitialComplianceInfo === 'function', 'createInitialComplianceInfo is a function');
|
|
|
|
assert.deepEqual(createInitialComplianceInfo(mockId), initialComplianceInfo, 'generates policy in expected shape');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Compliance utility function fieldChangeSetRequiresReview exists', function(assert) {
|
|
|
|
assert.ok(typeof fieldChangeSetRequiresReview === 'function', 'fieldChangeSetRequiresReview is a function');
|
|
|
|
|
|
|
|
assert.ok(typeof fieldChangeSetRequiresReview() === 'boolean', 'fieldChangeSetRequiresReview returns a boolean');
|
|
|
|
});
|
|
|
|
|
2017-10-07 17:49:57 -07:00
|
|
|
test('fieldChangeSetRequiresReview correctly determines if a fieldChangeSet requires review', function(assert) {
|
2017-10-02 18:49:35 -07:00
|
|
|
assert.expect(mockFieldChangeSets.length);
|
|
|
|
|
|
|
|
mockFieldChangeSets.forEach(changeSet =>
|
|
|
|
assert.ok(fieldChangeSetRequiresReview(changeSet) === changeSet.__requiresReview__, changeSet.__msg__)
|
|
|
|
);
|
|
|
|
});
|
2017-10-07 17:49:57 -07:00
|
|
|
|
|
|
|
test('isRecentSuggestion exists', function(assert) {
|
|
|
|
assert.expect(1);
|
|
|
|
assert.ok(typeof isRecentSuggestion === 'function', 'isRecentSuggestion is a function');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('isRecentSuggestion correctly determines if a suggestion is recent or not', function(assert) {
|
|
|
|
assert.expect(mockTimeStamps.length);
|
|
|
|
|
|
|
|
mockTimeStamps.forEach(({ policyModificationTime, suggestionModificationTime, __isRecent__, __assertMsg__ }) => {
|
|
|
|
const recent = isRecentSuggestion(policyModificationTime, suggestionModificationTime);
|
|
|
|
assert.ok(recent === __isRecent__, `${__assertMsg__} isRecent? ${recent}`);
|
|
|
|
});
|
|
|
|
});
|