1
0
Fork 0
Commit Graph

128 Commits (28d74d70685e0824b5895979d7603587c87b651b)

Author SHA1 Message Date
Mike Gerwitz 28d74d7068 ValidStateMonitor: handle empty diff on past failure
See the description in the test case.  This is a bug fix.

* src/validate/ValidStateMonitor.js
  (_checkCauseFix): Do not consider an empty diff on a past failure to
    be a fix.

* test/validate/ValidStateMonitorTest.js: Add test.

DEV-2296
2017-01-30 00:29:25 -05:00
Mike Gerwitz 24180e704a Add DiffStore
* src/store/DiffStore.js: Add class.
* test/store/DiffStoreTest.js: Add test case.

DEV-2296
2017-01-30 00:29:25 -05:00
Mike Gerwitz 3289e42003 Update MemoryStore syntax to ES6
`#reduce` is much better.

* src/store/MemoryStore.js: Update syntax.

DEV-2296
2017-01-30 00:29:25 -05:00
Mike Gerwitz 282c0acf54 Store#clear to return self
* src/store/MemoryStore.js (clear): Promise resolve to self.
* src/store/Store.js (clear): Update docblock.
* test/store/MemoryStoreTest.js: Update test case accordingly.

DEV-2296
2017-01-30 00:29:25 -05:00
Mike Gerwitz b62673791b Add PatternProxy Store trait
Life is so much less miserable now that the project is supporting ES6.

* src/store/PatternProxy.js: Add trait.
* src/store/StorePatternError.js: Add Error.
* test/store/PatternProxyTest.js: Add test case.

DEV-2296
2017-01-30 00:29:15 -05:00
Mike Gerwitz 29fb75d1a3 ES6-ify ValidStateMonitor
This also helps to demonstrate how the more concise syntax improves
readability.

* src/validate/ValidStateMonitor.js: Syntax to ES6.

DEV-2296
2017-01-29 22:44:35 -05:00
Mike Gerwitz 4d981bd39f Store#add to return self
This allows for Promise chaining (and consequently temporary classes,
great for testing).

* src/store/MemoryStore.js
  (add): Resolve promise to self.
    Modify docblock.
* src/store/Store.js (add): Modify docblock.
* src/store/Cascading.js (add): Modify docblock.

* test/store/MemoryStoreTest.js: Modify test accordingly.

DEV-2296
2017-01-29 22:44:34 -05:00
Mike Gerwitz 38b4a58dde Began system/ with client
This will contain various factories (compounded in some cases) to
instantiate various parts of a coherent system.  It aims to replace
(as one of many pieces) the ClientDependencyFactory that's referenced
in the code, which is still part of rating-fw (internal LoVullo repo
from which liza is being liberated).

* src/system/client.js: Add module.
* test/system/clientTest.js: Add functional test case.

DEV-2296
2017-01-29 22:44:34 -05:00
Mike Gerwitz 2045c76f7e Integrate Store into DataValidator, ValidStateMonitor
ValidStateMonitor now uses a Store in place of the original primitive
object-based diff format.  The original format is translated by
DataValidator.  The code is in a transitional state, and considering
the amount of time we spend on various areas of this project, will
likely stay this way for a while.

* src/validate/DataValidator.js
  (__construct): Accept Store factory parameter.
  (_store_factory): Add field.
  (_createStores): Add method.
  (_validate): Handle Store.
  (updateFailures): Add method.
  (_populateStore): Add method.

* test/validate/DataValidatorTest.js: Add tests.

* src/validate/ValidStateMonitor.js
  (update): Enforce Store diff.
    Wait to process failures until fixes are calculated.
  (_checkFailureFix): Handle asynchronous, Promise-based diff.
  (_checkCauseFix): Extract logic from _checkCauseFix.

* test/validate/ValidStateMonitorTest.js:
  Modify test cases to be Promise-based and handle async calls where
  appropriate.  That was a friggin' expensive mess.

DEV-2296
2017-01-29 22:44:27 -05:00
Mike Gerwitz 203b25f10e Add DataValidator
This extracts some gross code from Client in the rating-fw repo, which
is responsible for gluing change validations together.

* src/validate/DataValidator.js: Add class.
* test/validate/DataValidatorTest.js: Add test case.

DEV-2296
2017-01-27 15:57:43 -05:00
Mike Gerwitz c8d77085ec Make BucketDataValidator public methods virtual
This class is terribly factored and not tested.

* src/validate/BucketDataValidator.js
  (validate,format): Make methods virtual.

DEV-2296
2017-01-27 15:57:43 -05:00
Mike Gerwitz fb3cd11265 ValidStateMonitor#update return Promise
Stepping stone to async. fix checks.

* src/validate/ValidStateMonitor.js
  (update, detectFixes, _checkFailureFix): Return Promise.
* test/validate/ValidStateMonitorTest.js: Update to use promises.

DEV-2296
2017-01-27 15:57:40 -05:00
Mike Gerwitz 0c18a6321a Add StoreMissError
Nice and trivial with the new easejs transparent error subtyping!

* src/store/StoreMissError.js: Add error class.
* src/store/MemoryStore.js (get): Use it.
* test/store/MemoryStoreTest.js (#get): Modify test to expect type.
2017-01-04 16:17:37 -05:00
Mike Gerwitz 7d97569027 Add MissLookup trait
* src/store/MissLookup.js: Add trait.
* test/store/MissLookupTest.js: Add test case.
2017-01-04 16:17:37 -05:00
Mike Gerwitz 0be39adfdb Make {,Memory}Store asynchronous
This isn't terribly useful as a general-purpose cache if it can't
handle async requests.
2017-01-04 16:17:35 -05:00
Mike Gerwitz 29f67bd157 Add store.Cascading
* src/store/Cascading.js: Add trait.
* test/store/CascadingTest.js: Add test case.
2017-01-03 09:11:18 -05:00
Mike Gerwitz d8d44130e8 Add {,Memory}Store
* src/store/Store.js: Add interface.
* src/store/MemoryStore.js: Add class.
* test/store/MemoryStoreTest.js: Add test case.
2017-01-03 09:10:53 -05:00
Mike Gerwitz e883c45e35 Add Currency formatter
* src/validate/formatter/Currency.js: Add class.
2016-12-01 12:44:09 -05:00
Mike Gerwitz 5607bf1927 Replace Currency formatter with StringFormat
This is a much more general solution.

* src/validate/formatter/Currency.js: Remove trait.
* test/validate/formatter/CurrencyTest.js: Remove test case.

* src/validate/formatter/StringFormat.js: Add trait.
* test/validate/formatter/StringFormatTest.js: Add test case.
2016-12-01 08:47:23 -05:00
Mike Gerwitz ab3f5f4cb6 Validate correct Number format
* src/validate/formatter/Number.js
  (parse): Validate number format.

* test/validate/formatter/NumberTest.js: Modify accordingly.
2016-12-01 08:43:51 -05:00
Mike Gerwitz 5947e7646e Add scale to Number formatter
* src/validate/formatter/Number.js
  (__mixin): Add mixin ctor.
  (parse): Handle scale.
  (styleNumber): Handle scale.
  (scale, split): Add methods.

* test/validate/formatter/NumberTest.js: Modified accordingly.
2016-12-01 08:43:46 -05:00
Mike Gerwitz 6db99c8632 Add Currency formatter
* src/validate/formatter/Currency.js: Add trait.
* test/validate/formatter/CurrencyTest.js: Add test case.
2016-11-28 14:01:44 -05:00
Mike Gerwitz 14711cd4c6 Correct Number formatter docblock
* src/validate/formatter/Number.js: Correct trait docblock.
2016-11-28 14:01:09 -05:00
Mike Gerwitz c124086673 Correct and test GeneralStepUi#scrollTo
* src/ui/step/GeneralStepUi.js (scrollTo):
  Will now abort after each error rather than falling through.
  Visibility error message will now show field index.

* test/ui/step/GeneralStepUiTest.js: Added respective test cases
2016-08-05 11:45:09 -04:00
Mike Gerwitz 66f78c8886 Accept jQuery in GeneralStepUi
This defaults to the global jQuery just so we don't break
everything (BC); that'll be removed in the future.

* src/ui/step/GeneralStepUi.js (__construct): Accept jQuery.
  (setContent): Use jQuery instance passed via ctor
2016-08-05 11:41:27 -04:00
Mike Gerwitz 72f29a9734 Corrected GeneralStepUi class name
* src/ui/step/GeneralStepUi.js: Class name {=>General}StepUi
2016-07-28 16:25:47 -04:00
Mike Gerwitz 8d68880712 Remove multitext answer styler
This can now be handled with the existing formatters, specifically the
MultiDimension trait.  Specifically, multitext simply handled the
styling of vectors.

* src/ui/ElementStyler.js (_answerStylers): Remove multilimit
2016-07-20 15:23:35 -04:00
Mike Gerwitz d0768e20ca Remove now-unneeded answer stylers
There are more to be removed; baby steps.

* src/ui/ElementStyler.js
  (_answerStylers.{limit,multilimit,acceptReject,limitReject): Removed
2016-06-28 10:27:59 -04:00
Mike Gerwitz 5ce106710e Add MultiDimension formatter
* src/validate/formatter/MultiDimension.js: Added
* test/validate/formatter/MultiDimensionTest.js: Added
2016-06-28 10:27:59 -04:00
Mike Gerwitz 8feb8f286a Add StandardLimitFormatter
This formats according to common insurance conventions for limits.

* src/validate/formatter/insurance/StandardLimitFormatter.js: Added.
2016-06-28 10:27:59 -04:00
Mike Gerwitz b90f6d7474 Add accept/reject styler
* src/validate/formatter/AcceptReject.js: Added.
* test/validate/formatter/AcceptRejectTest.js: Added.
2016-06-28 10:27:56 -04:00
Mike Gerwitz 31f3ab010e Add Limit formatter
* src/validate/formatter/insurance/Limit.js: Added
* test/validate/formatter/insurance/LimitTest.js: Added
2016-06-27 16:51:25 -04:00
Mike Gerwitz c0df3ef02e Add Number formatter
* src/validate/formatter/Number.js: Added
* test/validate/formatter/NumberTest.js: Added
2016-06-27 16:51:25 -04:00
Mike Gerwitz 8a26406468 Add MultiDelimited formatter trait
This will simplify, through composition, a number of other
validator-formatters.

* src/validate/formatter/MultiDelimited.js: Added
* test/validate/formatter/MultiDelimitedTest.js: Added
2016-06-27 16:51:17 -04:00
Mike Gerwitz 4aa88fc08c UnorderedList{Formatter=>} now a trait
This adds a great deal of flexibility through composition via trait
stacking.

* src/validate/formatter/UnorderedList.js: Renamed from
  UnorderedListFormatter; now a trait.

* test/validate/formatter/UnorderedListTest.js: Renamed from
  UnorderedListFormatterTest and adjusted to instantiate trait.
2016-06-24 15:57:10 -04:00
Mike Gerwitz ac52f42d1c Add EchoFormatter
* src/validate/formatter/EchoFormatter.js: Added.
* test/validate/formatter/EchoFormatterTest.js: Added.
2016-06-23 10:12:59 -04:00
Mike Gerwitz 391a819536 Liberated UnorderedListFormatter
These have been refacored from the original: rather than abusing what is now
the PatternFormatter, it is now its own class.

* src/validate/formatter/UnorderedListFormatter.js: Added.
* test/validate/formatter/UnorderedListFormatterTest.js: Added.
2016-06-23 09:14:05 -04:00
Mike Gerwitz d6cecf1ff6 VFormat => PatternFormatter with added interface
* src/validate/ValidatorFormatter.js: Interface added.
* src/validate/formatter/PatternFormatter.js: Renamed from ../VFormat.js.
* test/validate/formatter/PatternFormatterTest.js: Renamed from
  ../VFormatTest.js.
2016-06-22 15:59:12 -04:00
Mike Gerwitz a509e53a3e Liberate VFormat
This will likely undergo some refactoring.

* src/validate/VFormat.js: Added.
* test/validate/VFormatTest.js: Added.
2016-06-22 15:41:03 -04:00
Mike Gerwitz 2a6b170ac9 Remove unneeded answer stylers
These all have VFormat alternatives.

* src/ui/ElementStyler.js (_answerStylers): Removed
2016-06-21 16:46:21 -04:00
Mike Gerwitz f5549795d5 GeneralStepUi vformat styling
* package.json (devDependencies): Add sinon

* src/ui/step/GeneralStepUi.js (answerDataUpdate): Attempt formatting with
  formatter prior to "old" answer styling.

* test/ui/step/GeneralStepUiTest.js: Added
2016-06-21 16:46:05 -04:00
Mike Gerwitz 91903951c4 Extract direct answer context references into method
This allows overriding for testing (and is a proper abstraction); eventually
this will be moved out of this class entirely.

* src/ui/step/GeneralStepUi.js (getAnswerContext): Added
  Number of methods updated to use.
2016-06-20 10:29:44 -04:00
Mike Gerwitz 7a1e1a68e3 GeneralStepUi answer styling method extraction
This is just to enable some sort of testing without instantiating the entire
class and navigating a maze of methods.

* ui/step/GeneralStepUi.js (answerDataUpdate): Added
  (_processAnswerFields): Extracted function into answerDataUpate
2016-06-17 14:44:49 -04:00
Mike Gerwitz e6ede4ad3a ValidStateMonitor: merge subsequent failures before fixes
* src/validate/ValidStateMonitor.js (mergeFailures):
Another error on a field that previously failed will no longer overwrite the
previous failure, which caused issue when the causes changed (leaving fields
potentially unfixed).

* test/validate/ValidStateMonitorTest.js: Respective tests added.
2016-04-28 11:53:14 -04:00
Mike Gerwitz e406c198d2 Add Failure#merge
* src/validate/Failure.js (merge): Added
* test/validate/FailureTest.js: Respective tests added
2016-04-28 11:31:42 -04:00
Mike Gerwitz b3d3f4b7cd Remove support for string-style validation failures
* src/validate/ValidStateMonitor (_getCauses): Removed
Now requires that each failure be a Failure object.
2016-04-21 16:28:34 -04:00
Mike Gerwitz 0a8329b405 Support multiple validation failure causes
* src/validate/Failure.js (__construct): Takes an array of causes.
(getCauses): Now returns an array of causes.

* src/validate/ValidStateMonitor.js: Recognize fixes on array of causes.

* test/validate/FailureTest.js: Updated

* test/validate/ValidStateMonitorTest.js: Updated
2016-04-21 16:23:41 -04:00
Mike Gerwitz f624710451 Consider field failure cause when checking fixes
This maintains BC with the old string-based system.

* src/validate/ValidStateMonitor.js (_getCause): Added.
(detectFixes): Consider failure cause if available when checking for fixes.
2016-04-20 12:11:17 -04:00
Mike Gerwitz ac5d04e9a4 Add validation Failure
* src/validate/Failure.js: Added
* test/validate/FailureTtest.js: Added
2016-04-20 10:31:49 -04:00
Mike Gerwitz ddffb4e301 No failure event if failures have not changed in ValidStateMonitor
* src/validate/ValidStateMonitor.js (mergeFailures): Return count of new
failures

* test/validate/ValidStateMonitorTest.js: Respective test added
2016-04-19 11:29:14 -04:00