forked from json-schema-form/angular-schema-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsf-message.directive.spec.js
58 lines (48 loc) · 1.43 KB
/
sf-message.directive.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* eslint-disable quotes, no-var */
/* disabling quotes makes it easier to copy tests into the example app */
chai.should();
var runSync = function(scope, tmpl) {
var directiveScope = tmpl.isolateScope();
sinon.stub(directiveScope, 'resolveReferences', function(schema, form) {
directiveScope.render(schema, form);
});
scope.$apply();
};
describe('sf-message.directive.js', function() {
beforeEach(module('schemaForm'));
beforeEach(
module(function($sceProvider) {
$sceProvider.enabled(false);
})
);
it('should watch description for changes', function(done) {
var exampleSchema = {
"type": "object",
"properties": {
"name": {
"title": "Name",
"type": "string",
},
},
};
inject(function($compile, $rootScope) {
var scope = $rootScope.$new();
scope.person = {};
scope.schema = exampleSchema;
scope.form = [{
key: 'name',
description: 'foobar',
}];
var tmpl = angular.element('<form sf-schema="schema" sf-form="form" sf-model="person"></form>');
$compile(tmpl)(scope);
runSync(scope, tmpl);
tmpl.children().find('div.help-block').text().should.equal('foobar');
setTimeout(function() {
scope.form[0].description = 'changed';
scope.$apply();
tmpl.children().find('div.help-block').text().should.equal('changed');
done();
}, 0);
});
});
});