@@ -12,44 +12,52 @@ describe('uiCodemirror', function () {
12
12
scope = _$rootScope_ . $new ( ) ;
13
13
$compile = _$compile_ ;
14
14
} ) ) ;
15
+
15
16
afterEach ( function ( ) {
16
17
angular . module ( 'ui.config' ) . value ( 'ui.config' , { } ) ; // cleanup
17
18
} ) ;
19
+
18
20
describe ( 'compiling this directive' , function ( ) {
19
21
it ( 'should throw an error if used against a non-textarea' , function ( ) {
20
22
function compile ( ) {
21
23
$compile ( '<div ui-codemirror ng-model="foo"></div>' ) ( scope ) ;
22
24
}
23
25
expect ( compile ) . toThrow ( ) ;
24
26
} ) ;
27
+
25
28
it ( 'should not throw an error when used against a textarea' , function ( ) {
26
29
function compile ( ) {
27
30
$compile ( '<textarea ui-codemirror ng-model="foo"></textarea>' ) ( scope ) ;
28
31
}
29
32
expect ( compile ) . not . toThrow ( ) ;
30
33
} ) ;
34
+
31
35
it ( 'should throw an error when no ngModel attribute defined' , function ( ) {
32
36
function compile ( ) {
33
37
$compile ( '<textarea ui-codemirror></textarea>' ) ( scope ) ;
34
38
}
35
39
expect ( compile ) . toThrow ( ) ;
36
40
} ) ;
41
+
37
42
it ( 'should watch the uiCodemirror attribute' , function ( ) {
38
43
spyOn ( scope , '$watch' ) ;
39
44
$compile ( '<textarea ui-codemirror ng-model="foo"></textarea>' ) ( scope ) ;
40
45
expect ( scope . $watch ) . toHaveBeenCalled ( ) ;
41
46
} ) ;
47
+
42
48
it ( 'should include the passed options' , function ( ) {
43
49
spyOn ( CodeMirror , 'fromTextArea' ) ;
44
50
$compile ( '<textarea ui-codemirror="{foo: \'bar\'}" ng-model="foo"></textarea>' ) ( scope ) ;
45
51
expect ( CodeMirror . fromTextArea . mostRecentCall . args [ 1 ] . foo ) . toEqual ( 'bar' ) ;
46
52
} ) ;
53
+
47
54
it ( 'should include the default options' , function ( ) {
48
55
spyOn ( CodeMirror , 'fromTextArea' ) ;
49
56
$compile ( '<textarea ui-codemirror ng-model="foo"></textarea>' ) ( scope ) ;
50
57
expect ( CodeMirror . fromTextArea . mostRecentCall . args [ 1 ] . bar ) . toEqual ( 'baz' ) ;
51
58
} ) ;
52
59
} ) ;
60
+
53
61
describe ( 'when the model changes' , function ( ) {
54
62
it ( 'should update the IDE' , function ( ) {
55
63
var element = $compile ( '<textarea ui-codemirror ng-model="foo"></textarea>' ) ( scope ) ;
@@ -58,6 +66,7 @@ describe('uiCodemirror', function () {
58
66
expect ( element . siblings ( ) . text ( ) . trim ( ) ) . toBe ( scope . foo ) ;
59
67
} ) ;
60
68
} ) ;
69
+
61
70
describe ( 'when the IDE changes' , function ( ) {
62
71
it ( 'should update the model' , function ( ) {
63
72
var codemirror ,
@@ -74,6 +83,7 @@ describe('uiCodemirror', function () {
74
83
expect ( scope . foo ) . toBe ( value ) ;
75
84
} ) ;
76
85
} ) ;
86
+
77
87
describe ( 'when the model is undefined/null' , function ( ) {
78
88
it ( 'should update the IDE with an empty string' , function ( ) {
79
89
var element = $compile ( '<textarea ui-codemirror ng-model="foo"></textarea>' ) ( scope ) ;
@@ -86,6 +96,7 @@ describe('uiCodemirror', function () {
86
96
expect ( element . siblings ( ) . text ( ) . trim ( ) ) . toBe ( '' ) ;
87
97
} ) ;
88
98
} ) ;
99
+
89
100
describe ( 'when the model is an object or an array' , function ( ) {
90
101
it ( 'should throw an error' , function ( ) {
91
102
function compileWithObject ( ) {
0 commit comments