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

Commit d8906a6

Browse files
BarryThePenguinKent C. Dodds
authored andcommitted
test(formly-form): field watcher setup and error
1 parent 460ead5 commit d8906a6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/directives/formly-form.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,5 +869,38 @@ describe('formly-form', () => {
869869
return el;
870870
}
871871

872+
describe(`field watchers`, () => {
873+
it('should throw for a watcher with no listener', () => {
874+
scope.fields = [getNewField({
875+
watcher: {}
876+
})];
872877

878+
expect(compileAndDigest).to.throw();
879+
});
880+
881+
it(`should setup any watchers specified on a field`, () => {
882+
scope.model = {};
883+
884+
const listener = sinon.spy();
885+
const expression = sinon.spy();
886+
887+
scope.fields = [getNewField({
888+
watcher: {
889+
listener: ''
890+
}
891+
}), getNewField({
892+
watcher: [{
893+
listener: '',
894+
expression: ''
895+
}, {
896+
listener,
897+
expression
898+
}]
899+
})];
900+
901+
expect(compileAndDigest).to.not.throw();
902+
expect(listener).to.have.been.called;
903+
expect(expression).to.have.been.called;
904+
});
905+
});
873906
});

0 commit comments

Comments
 (0)