Exemple #1
0
    it('should remove condition from collection and column index from orderStack', function () {
      var conditionCollection = new ConditionCollection();
      var conditionMock = {};

      spyOn(conditionCollection, 'clearConditions');
      conditionCollection.orderStack = [3];
      conditionCollection.conditions['3'] = [conditionMock];

      conditionCollection.removeConditions(3);

      expect(conditionCollection.orderStack).toEqual([]);
      expect(conditionCollection.clearConditions).toHaveBeenCalledWith(3);
    });
Exemple #2
0
    it('should trigger `beforeRemove` and `afterRemove` hook on removing conditions', function () {
      var conditionCollection = new ConditionCollection();
      var conditionMock = {};

      conditionCollection.orderStack = [3];
      conditionCollection.conditions['3'] = [conditionMock];

      var hookBeforeSpy = jasmine.createSpy('hookBefore');
      var hookAfterSpy = jasmine.createSpy('hookAfter');

      conditionCollection.addLocalHook('beforeRemove', hookBeforeSpy);
      conditionCollection.addLocalHook('afterRemove', hookAfterSpy);
      conditionCollection.removeConditions(3);

      expect(hookBeforeSpy).toHaveBeenCalledWith(3);
      expect(hookAfterSpy).toHaveBeenCalledWith(3);
    });