@@ -4,19 +4,18 @@ describe('uiTinymce', function () {
4
4
5
5
var scope , $compile , element , text = '<p>Hello</p>' ;
6
6
beforeEach ( module ( 'ui.tinymce' ) ) ;
7
- beforeEach ( function ( ) {
7
+ beforeEach ( function ( ) {
8
8
// throw some garbage in the tinymce cfg to be sure it's getting thru to the directive
9
9
angular . module ( 'ui.tinymce' ) . value ( 'uiTinymceConfig' , { tinymce : { bar : 'baz' } } ) ;
10
10
} ) ;
11
- beforeEach ( inject ( function ( _$rootScope_ , _$compile_ ) {
11
+ beforeEach ( inject ( function ( _$rootScope_ , _$compile_ ) {
12
12
scope = _$rootScope_ . $new ( ) ;
13
13
$compile = _$compile_ ;
14
14
} ) ) ;
15
15
16
- afterEach ( function ( ) {
16
+ afterEach ( function ( ) {
17
17
angular . module ( 'ui.tinymce' ) . value ( 'uiTinymceConfig' , { } ) ;
18
18
tinymce . remove ( 'textarea' ) ;
19
- element . remove ( ) ;
20
19
} ) ;
21
20
22
21
/**
@@ -28,84 +27,86 @@ describe('uiTinymce', function () {
28
27
scope . $apply ( ) ;
29
28
}
30
29
31
- describe ( 'compiling this directive' , function ( ) {
30
+ describe ( 'compiling this directive' , function ( ) {
32
31
33
- it ( 'should include the passed options' , function ( done ) {
32
+ it ( 'should include the passed options' , function ( ) {
34
33
spyOn ( tinymce , 'init' ) ;
35
34
compile ( ) ;
36
- setTimeout ( function ( ) {
37
- expect ( tinymce . init ) . toHaveBeenCalled ( ) ;
38
- expect ( tinymce . init . calls . mostRecent ( ) . args [ 0 ] . foo ) . toBe ( 'bar' ) ;
39
- done ( ) ;
40
- } ) ;
35
+ expect ( tinymce . init ) . toHaveBeenCalled ( ) ;
36
+ expect ( tinymce . init . calls . mostRecent ( ) . args [ 0 ] . foo ) . toBe ( 'bar' ) ;
41
37
} ) ;
42
38
43
- it ( 'should include the default options' , function ( done ) {
39
+ it ( 'should include the default options' , function ( ) {
44
40
spyOn ( tinymce , 'init' ) ;
45
41
compile ( ) ;
46
- setTimeout ( function ( ) {
47
- expect ( tinymce . init ) . toHaveBeenCalled ( ) ;
48
- expect ( tinymce . init . calls . mostRecent ( ) . args [ 0 ] . tinymce . bar ) . toBe ( 'baz' ) ;
49
- done ( ) ;
50
- } ) ;
42
+ expect ( tinymce . init ) . toHaveBeenCalled ( ) ;
43
+ expect ( tinymce . init . calls . mostRecent ( ) . args [ 0 ] . tinymce . bar ) . toBe ( 'baz' ) ;
51
44
} ) ;
52
45
53
- it ( 'should execute the passed `setup` option' , function ( done ) {
46
+ it ( 'should execute the passed `setup` option' , function ( ) {
54
47
scope . setupFooBar = jasmine . createSpy ( 'setupFooBar' ) ;
55
48
compile ( ) ;
56
- setTimeout ( function ( ) {
57
- expect ( scope . setupFooBar ) . toHaveBeenCalled ( ) ;
58
- done ( ) ;
59
- } ) ;
49
+ expect ( scope . setupFooBar ) . toHaveBeenCalled ( ) ;
60
50
} ) ;
61
51
} ) ;
62
52
63
- it ( 'should remove tinymce instance on $scope destruction' , function ( done ) {
53
+ it ( 'should remove tinymce instance on $scope destruction' , function ( ) {
64
54
compile ( ) ;
65
- setTimeout ( function ( ) {
66
- expect ( tinymce . get ( 'foo' ) ) . toBeDefined ( ) ;
55
+ expect ( tinymce . get ( 'foo' ) ) . toBeDefined ( ) ;
67
56
68
- scope . $destroy ( ) ;
57
+ scope . $destroy ( ) ;
69
58
70
- expect ( tinymce . get ( 'foo' ) ) . toBeNull ( ) ;
71
-
72
- done ( ) ;
73
- } ) ;
59
+ expect ( tinymce . get ( 'foo' ) ) . toBeNull ( ) ;
74
60
} ) ;
75
61
76
- describe ( 'setting a value to the model' , function ( ) {
62
+ describe ( 'setting a value to the model' , function ( ) {
77
63
it ( 'should update the editor' , function ( done ) {
78
64
compile ( ) ;
79
- setTimeout ( function ( ) {
65
+ setTimeout ( function ( ) {
80
66
scope . foo = text ;
81
67
scope . $apply ( ) ;
82
68
83
- expect ( tinymce . get ( 'foo' ) . getContent ( ) ) . toEqual ( text ) ;
69
+ try {
70
+ expect ( tinymce . get ( 'foo' ) . getContent ( ) ) . toEqual ( text ) ;
71
+ } catch ( e ) {
72
+ expect ( true ) . toBe ( false ) ;
73
+ done ( ) ;
74
+ }
84
75
85
76
done ( ) ;
86
- } ) ;
77
+ } , 20 ) ;
87
78
} ) ;
88
- it ( 'should handle undefined gracefully' , function ( done ) {
79
+ it ( 'should handle undefined gracefully' , function ( done ) {
89
80
compile ( ) ;
90
- setTimeout ( function ( ) {
81
+ setTimeout ( function ( ) {
91
82
scope . foo = undefined ;
92
83
scope . $apply ( ) ;
93
84
94
- expect ( tinymce . get ( 'foo' ) . getContent ( ) ) . toEqual ( '' ) ;
85
+ try {
86
+ expect ( tinymce . get ( 'foo' ) . getContent ( ) ) . toEqual ( '' ) ;
87
+ } catch ( e ) {
88
+ expect ( true ) . toBe ( false ) ;
89
+ done ( ) ;
90
+ }
95
91
96
92
done ( ) ;
97
- } ) ;
93
+ } , 20 ) ;
98
94
} ) ;
99
- it ( 'should handle null gracefully' , function ( done ) {
95
+ it ( 'should handle null gracefully' , function ( done ) {
100
96
compile ( ) ;
101
- setTimeout ( function ( ) {
97
+ setTimeout ( function ( ) {
102
98
scope . foo = null ;
103
99
scope . $apply ( ) ;
104
100
105
- expect ( tinymce . get ( 'foo' ) . getContent ( ) ) . toEqual ( '' ) ;
101
+ try {
102
+ expect ( tinymce . get ( 'foo' ) . getContent ( ) ) . toEqual ( '' ) ;
103
+ } catch ( e ) {
104
+ expect ( true ) . toBe ( false ) ;
105
+ done ( ) ;
106
+ }
106
107
107
108
done ( ) ;
108
- } ) ;
109
+ } , 20 ) ;
109
110
} ) ;
110
111
} ) ;
111
112
/*describe('using the editor', function () {
0 commit comments