Skip to content

Commit

Permalink
Changed approach to console messages testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwaliszko committed Aug 10, 2017
1 parent f39e431 commit 9e9bb92
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 63 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ AllowEmptyStrings - Gets or sets a flag indicating whether the attribute should
or whitespace strings. False by default.
Priority - Gets or sets the hint, available for any concerned external components,
indicating the order in which this attribute should be executed among
others of its kind, i.e. ExpressiveAttribute. Value is optional and not
set by default, which means that execution order is undefined.
others of its kind. Value is optional and not set by default, which
means that execution order is undefined.
ErrorMessage - Gets or sets an explicit error message string. A difference to default
behavior is awareness of new format items, i.e. {fieldPath[:indicator]}.
Given in curly brackets, can be used to extract values of specified
Expand Down Expand Up @@ -688,7 +688,7 @@ Finally, there is a possibility to override built-in conversion globally. In thi

```JavaScript
<script>
ea.addValueParser('typename', function (value) {
ea.addValueParser('typename', function(value) {
return ... // handle specified type (numeric, datetime, etc.) parsing on your own
});
```
Expand Down Expand Up @@ -808,17 +808,15 @@ EA does not provide any built-in mechanisms to manipulate DOM. Nevertheless, the
$('form').find(selector).on('eavalid', function(e, type, valid, expr, cond, idx) { // verify asterisk visibility based on computed condition
if (type === 'requiredif' && cond !== undefined) {
if (idx === 0) { // if first of its kind...
e.currentTarget.eacond = undefined; // ...reset asterisk visibility flag
e.currentTarget.eacond = false; // ...reset asterisk visibility flag
}
e.currentTarget.eacond |= cond; // multiple requiredif attributes can be applied to a single field - remember if any condition is true
var li = $(e.currentTarget).closest('li');
var asterisk = li.find('.asterisk');

if (e.currentTarget.eacond) {
asterisk.show(); // show asterisk for required fields (no matter if valid or not)
$(e.currentTarget).closest('li').find('.asterisk').show(); // show asterisk for required fields (no matter if valid or not)
}
else {
asterisk.hide();
$(e.currentTarget).closest('li').find('.asterisk').hide();
}
}
});
Expand Down Expand Up @@ -916,7 +914,7 @@ Next, make the mocked field clone the behavior of the original (from parent) one
});
}

$(document).ready(function () {
$(document).ready(function() {
Mimic('input[name="@Html.NameFor(m => m.Flag)"]',
'input[name="@Html.NameFor(m => m.Child.Parent.Flag)"]');
});
Expand Down
2 changes: 1 addition & 1 deletion src/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Chutzpah" version="4.2.3" />
<package id="Chutzpah" version="4.2.4" />
<package id="OpenCover" version="4.6.519" />
<package id="xunit.runner.console" version="2.1.0" />
</packages>
17 changes: 10 additions & 7 deletions src/expressive.annotations.validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'use strict';
var
backup = window.ea, // map over the ea in case of overwrite
buffer = window.console,

api = { // to be accessed from outer scope
settings: {
Expand Down Expand Up @@ -85,18 +86,18 @@ var

logger = {
info: function(message) {
if (api.settings.debug && console && typeof console.log === 'function') { // flush in debug mode only
console.log('[info] ' + logger.prep(message, new Date()));
if (api.settings.debug && buffer && typeof buffer.log === 'function') { // flush in debug mode only
buffer.log('[info] ' + logger.prep(message, new Date()));
}
},
warn: function(message) {
if (console && typeof console.warn === 'function') {
console.warn('[warn] ' + logger.prep(message, new Date()));
if (buffer && typeof buffer.warn === 'function') {
buffer.warn('[warn] ' + logger.prep(message, new Date()));
}
},
fail: function(message) {
if (console && typeof console.error === 'function') {
console.error('[fail] ' + logger.prep(message, new Date()));
if (buffer && typeof buffer.error === 'function') {
buffer.error('[fail] ' + logger.prep(message, new Date()));
}
},
prep: function(message, date) {
Expand Down Expand Up @@ -856,7 +857,9 @@ var
modelHelper: modelHelper,
validationHelper: validationHelper,
computeRequiredIf: computeRequiredIf,
computeAssertThat: computeAssertThat
computeAssertThat: computeAssertThat,
getBuffer: function() { return buffer; },
setBuffer: function(buff) { buffer = buff; }
};
// !debug section leave ----------------------------------------

Expand Down
Loading

0 comments on commit 9e9bb92

Please sign in to comment.