Add tests for CaseTypeListCtrl's revertCaseType method
authorRené Olivo <minet.ws@gmail.com>
Tue, 24 Apr 2018 00:02:04 +0000 (20:02 -0400)
committerRené Olivo <minet.ws@gmail.com>
Tue, 24 Apr 2018 00:02:04 +0000 (20:02 -0400)
tests/karma/unit/crmCaseTypeSpec.js

index e6c8aa944f0218b1c467d53b331f1794257c6378..4f67bc0f1143087d088125d9b401bc3d9252e5fe 100644 (file)
@@ -390,6 +390,28 @@ describe('crmCaseType', function() {
           expect(CRM.alert).toHaveBeenCalledWith(error.error_message, ts('Error'), 'error');
         });
       });
+
+      describe('revertCaseType', function() {
+        var caseType = {
+          id: _.uniqueId(),
+          definition: {},
+          is_forked: '1'
+        };
+
+        describe('when reverting a case type', function() {
+          beforeEach(function() {
+            scope.revertCaseType(caseType);
+          });
+
+          it('resets the case type information using the api', function() {
+            expect(crmApiSpy).toHaveBeenCalledWith('CaseType', 'create', jasmine.objectContaining({
+              id: caseType.id,
+              definition: 'null',
+              is_forked: '0'
+            }), true);
+          });
+        });
+      });
     });
   });
 });