-
Notifications
You must be signed in to change notification settings - Fork 649
/
Copy pathschema-form-decorators.provider.spec.js
79 lines (68 loc) · 3.6 KB
/
schema-form-decorators.provider.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
chai.should();
describe('schemaFormDecorators', function() {
beforeEach(module('schemaForm'));
// describe('#legacy #createDecorator', function() {
// it('should enable you to create new decorator directives', function() {
// module(function(schemaFormDecoratorsProvider) {
// schemaFormDecoratorsProvider.createDecorator('foobar', { 'foo': '/bar.html' }, [ angular.noop ]);
// });
//
// inject(function($rootScope, $compile, $templateCache) {
// $templateCache.put('/bar.html', '<div class="yes">YES</div>');
//
// //Since our directive does a replace we need a wrapper to actually check the content.
// var templateWithWrap = angular.element('<div id="wrap"><foobar form="{ type: \'foo\'}"></foobar></div>');
// var template = templateWithWrap.children().eq(0);
//
// $compile(template)($rootScope);
// $rootScope.$apply();
// templateWithWrap.children().length.should.equal(1);
// templateWithWrap.children().is('foobar').should.be.true;
// templateWithWrap.children().eq(0).children().length.should.equal(1);
// templateWithWrap.children().eq(0).children().is('div').should.be.true;
// templateWithWrap.children().eq(0).children().hasClass('yes').should.be.true;
// });
// });
// });
describe('#legacy #defineDecorator', function() {
it('should enable you to create new decorator directives', function() {
module(function(schemaFormDecoratorsProvider) {
schemaFormDecoratorsProvider.defineDecorator('foobar', { 'foo': { 'template': '/bar.html', 'builder': []}});
});
inject(function($rootScope, $compile, $templateCache) {
$templateCache.put('/bar.html', '<div class="yes">YES</div>');
//Since our directive does a replace we need a wrapper to actually check the content.
var templateWithWrap = angular.element('<div id="wrap"><foobar form="{ type: \'foo\'}"></foobar></div>');
var template = templateWithWrap.children().eq(0);
$compile(template)($rootScope);
$rootScope.$apply();
templateWithWrap.children().length.should.equal(1);
templateWithWrap.children().is('foobar').should.be.true;
templateWithWrap.children().eq(0).children().length.should.equal(1);
templateWithWrap.children().eq(0).children().is('div').should.be.true;
templateWithWrap.children().eq(0).children().hasClass('yes').should.be.true;
});
});
});
describe('#legacy #defineDecoratorWithRawTemplate', function() {
it('should enable you to create new decorator directives',function(){
module(function(schemaFormDecoratorsProvider){
schemaFormDecoratorsProvider.defineDecorator('foobar',{
'foo': {template: '<div class="yes">YES</div>', replace: true, type: 'template'}
},[angular.noop]);
});
inject(function($rootScope,$compile){
//Since our directive does a replace we need a wrapper to actually check the content.
var templateWithWrap = angular.element('<div id="wrap"><foobar form="{ type: \'foo\'}"></foobar></div>');
var template = templateWithWrap.children().eq(0);
$compile(template)($rootScope);
$rootScope.$apply();
templateWithWrap.children().length.should.equal(1);
templateWithWrap.children().is('foobar').should.be.true;
templateWithWrap.children().eq(0).children().length.should.equal(1);
templateWithWrap.children().eq(0).children().is('div').should.be.true;
templateWithWrap.children().eq(0).children().hasClass('yes').should.be.true;
});
});
});
});