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

Commit 2b316c5

Browse files
author
Kent C. Dodds
committed
test(formly-field): Nest describe for a section
1 parent 0368b76 commit 2b316c5

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

src/directives/formly-field.test.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,33 +1320,35 @@ 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(`with custom errorExistsAndShouldBeVisible expression`, () => {
1325+
beforeEach(() => {
1326+
scope.fields = [getNewField({validators: {foo: 'false'}})];
1327+
});
13271328

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;
1348-
});
1329+
it(`should set errorExistsAndShouldBeVisible to true when the expression function says so`, () => {
1330+
formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = '!!options.data.customExpression';
1331+
compileAndDigest();
1332+
expect(field.validation.errorExistsAndShouldBeVisible).to.be.false;
1333+
field.data.customExpression = true;
1334+
scope.$digest();
1335+
expect(field.validation.errorExistsAndShouldBeVisible).to.be.true;
1336+
});
13491337

1338+
it(`should be able to work with form.$submitted`, () => {
1339+
formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = 'form.$submitted';
1340+
compileAndDigest(`
1341+
<form name="theForm">
1342+
<formly-form form="theForm" model="model" fields="fields" options="options"></formly-form>
1343+
</form>
1344+
`);
1345+
expect(field.validation.errorExistsAndShouldBeVisible).to.be.false;
1346+
scope.theForm.$setSubmitted(true);
1347+
scope.$digest();
1348+
expect(field.validation.errorExistsAndShouldBeVisible).to.be.true;
1349+
});
1350+
1351+
});
13501352
});
13511353

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

0 commit comments

Comments
 (0)