Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit 4d7e212

Browse files
committed
v7.2.2
2 parents eaa7695 + bfaa147 commit 4d7e212

File tree

8 files changed

+120
-33
lines changed

8 files changed

+120
-33
lines changed

dist/formly.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* angular-formly JavaScript Library v7.2.1
2+
* angular-formly JavaScript Library v7.2.2
33
*
44
* @license MIT (http://license.angular-formly.com)
55
*
@@ -153,7 +153,7 @@ return /******/ (function(modules) { // webpackBootstrap
153153

154154
ngModule.constant('formlyApiCheck', _providersFormlyApiCheck2['default']);
155155
ngModule.constant('formlyErrorAndWarningsUrlPrefix', _otherDocsBaseUrl2['default']);
156-
ngModule.constant('formlyVersion', ("7.2.1")); // <-- webpack variable
156+
ngModule.constant('formlyVersion', ("7.2.2")); // <-- webpack variable
157157

158158
ngModule.provider('formlyUsability', _providersFormlyUsability2['default']);
159159
ngModule.provider('formlyConfig', _providersFormlyConfig2['default']);
@@ -422,7 +422,7 @@ return /******/ (function(modules) { // webpackBootstrap
422422
Object.defineProperty(exports, "__esModule", {
423423
value: true
424424
});
425-
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("7.2.1") + "/other/ERRORS_AND_WARNINGS.md#";
425+
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("7.2.2") + "/other/ERRORS_AND_WARNINGS.md#";
426426
module.exports = exports["default"];
427427

428428
/***/ },
@@ -546,6 +546,7 @@ return /******/ (function(modules) { // webpackBootstrap
546546
disableWarnings: false,
547547
extras: {
548548
disableNgModelAttrsManipulator: false,
549+
fieldTransform: [],
549550
ngModelAttrsManipulatorPreferUnbound: false,
550551
removeChromeAutoComplete: false,
551552
defaultHideDirective: 'ng-if',

dist/formly.min.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formly.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-formly",
3-
"version": "7.2.1",
3+
"version": "7.2.2",
44
"author": "Astrism <[email protected]>",
55
"contributors": [
66
"Astrism <[email protected]>",
@@ -59,7 +59,7 @@
5959
"babel-loader": "5.3.2",
6060
"chai": "3.3.0",
6161
"codecov.io": "0.1.6",
62-
"commitizen": "1.0.5",
62+
"commitizen": "2.0.2",
6363
"cracks": "3.1.1",
6464
"cross-env": "1.0.1",
6565
"cz-conventional-changelog": "1.1.4",

src/directives/formly-field.test.js

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,33 +1320,81 @@ describe('formly-field', function() {
13201320
});
13211321
});
13221322

1323-
describe(`with custom errorExistsAndShouldBeVisible expression`, () => {
1324-
beforeEach(() => {
1325-
scope.fields = [getNewField({validators: {foo: 'false'}})];
1326-
});
1323+
describe(`options.validation.errorExistsAndShouldBeVisible`, () => {
1324+
describe.skip(`multiple ng-model elements`, () => {
1325+
beforeEach(() => {
1326+
scope.fields = [
1327+
{
1328+
template: `
1329+
<input ng-model="model[options.data.firstKey]" />
1330+
<input ng-model="model[options.data.secondKey]" />
1331+
`,
1332+
// we'll just give it a validator that depends on a value we
1333+
// can change in our tests
1334+
validators: {foo: '!options.data.invalid'}
1335+
}
1336+
];
1337+
});
13271338

1328-
it(`should set errorExistsAndShouldBeVisible to true when the expression function says so`, () => {
1329-
formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = '!!options.data.customExpression';
1330-
compileAndDigest();
1331-
expect(field.validation.errorExistsAndShouldBeVisible).to.be.false;
1332-
field.data.customExpression = true;
1333-
scope.$digest();
1334-
expect(field.validation.errorExistsAndShouldBeVisible).to.be.true;
1335-
});
1336-
1337-
it(`should be able to work with form.$submitted`, () => {
1338-
formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = 'form.$submitted';
1339-
compileAndDigest(`
1340-
<form name="theForm">
1341-
<formly-form form="theForm" model="model" fields="fields" options="options"></formly-form>
1342-
</form>
1343-
`);
1344-
expect(field.validation.errorExistsAndShouldBeVisible).to.be.false;
1345-
scope.theForm.$setSubmitted(true);
1346-
scope.$digest();
1347-
expect(field.validation.errorExistsAndShouldBeVisible).to.be.true;
1339+
it(`should set showError to true when one of them is invalid`, () => {
1340+
compileAndDigest();
1341+
expect(field.validation.errorExistsAndShouldBeVisible, 'initially false').to.be.false;
1342+
invalidateAndTouchFields();
1343+
1344+
expect(field.formControl[0].$error.foo, '$error on the first formControl').be.true;
1345+
expect(field.validation.errorExistsAndShouldBeVisible, 'now true').to.be.true;
1346+
});
1347+
1348+
it(`should work with a custom errorExistsAndShouldBeVisibleExpression`, () => {
1349+
const spy = sinon.spy();
1350+
formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = spy;
1351+
compileAndDigest();
1352+
1353+
invalidateAndTouchFields();
1354+
expect(spy).to.have.been.calledWith(sinon.match.array, sinon.match.array);
1355+
});
1356+
1357+
function invalidateAndTouchFields() {
1358+
field.data.invalid = true;
1359+
// force $touched and revalidation of both form controls
1360+
field.formControl.forEach(fc => {
1361+
fc.$setTouched();
1362+
fc.$validate();
1363+
});
1364+
1365+
// redigest to set the showError prop
1366+
scope.$digest();
1367+
}
13481368
});
13491369

1370+
describe(`with custom errorExistsAndShouldBeVisible expression`, () => {
1371+
beforeEach(() => {
1372+
scope.fields = [getNewField({validators: {foo: 'false'}})];
1373+
});
1374+
1375+
it(`should set errorExistsAndShouldBeVisible to true when the expression function says so`, () => {
1376+
formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = '!!options.data.customExpression';
1377+
compileAndDigest();
1378+
expect(field.validation.errorExistsAndShouldBeVisible).to.be.false;
1379+
field.data.customExpression = true;
1380+
scope.$digest();
1381+
expect(field.validation.errorExistsAndShouldBeVisible).to.be.true;
1382+
});
1383+
1384+
it(`should be able to work with form.$submitted`, () => {
1385+
formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = 'form.$submitted';
1386+
compileAndDigest(`
1387+
<form name="theForm">
1388+
<formly-form form="theForm" model="model" fields="fields" options="options"></formly-form>
1389+
</form>
1390+
`);
1391+
expect(field.validation.errorExistsAndShouldBeVisible).to.be.false;
1392+
scope.theForm.$setSubmitted(true);
1393+
scope.$digest();
1394+
expect(field.validation.errorExistsAndShouldBeVisible).to.be.true;
1395+
});
1396+
1397+
});
13501398
});
13511399

13521400
describe(`with specified "model" property`, () => {

src/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import './directives/formly-custom-validation.test';
99
import './directives/formly-field.test';
1010
import './directives/formly-focus.test';
1111
import './directives/formly-form.test';
12+
import './run/formlyCustomTags.test';
1213
import './run/formlyNgModelAttrsManipulator.test';
1314
import './other/utils.test';
1415

src/providers/formlyConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function formlyConfig(formlyUsabilityProvider, formlyErrorAndWarningsUrlPrefix,
2424
disableWarnings: false,
2525
extras: {
2626
disableNgModelAttrsManipulator: false,
27+
fieldTransform: [],
2728
ngModelAttrsManipulatorPreferUnbound: false,
2829
removeChromeAutoComplete: false,
2930
defaultHideDirective: 'ng-if',

src/run/formlyCustomTags.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import angular from 'angular';
2+
3+
describe(`formlyCustomTags`, () => {
4+
5+
beforeEach(window.module(`formly`, $provide => {
6+
const docStub = {
7+
get: sinon.stub().withArgs(0).returnsThis(),
8+
createElement: sinon.stub().withArgs(`div`).returns({
9+
getElementsByTagName: sinon.stub().withArgs(`i`).returns([1])
10+
})
11+
};
12+
13+
$provide.value(`$document`, docStub);
14+
}));
15+
16+
let $document;
17+
18+
beforeEach(inject((_$document_) => {
19+
$document = _$document_;
20+
}));
21+
22+
describe(`addCustomTags`, () => {
23+
it(`should create custom formly tags`, () => {
24+
const customElements = [
25+
`div`, `formly-field`, `formly-form`, `formly-custom-validation`, `formly-focus`, `formly-transpose`
26+
];
27+
28+
expect($document.get).to.have.been.calledOnce;
29+
30+
angular.forEach(customElements, el => {
31+
expect($document.createElement).to.have.been.calledWith(el);
32+
});
33+
});
34+
});
35+
});

0 commit comments

Comments
 (0)