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
80
81
82
83
84
85
86
87
88
89
90
|
/*global describe, beforeEach, module, inject, it, spyOn, expect, $, angular, afterEach, runs, waits */
describe('uiTinymce', function () {
'use strict';
var scope, $compile, element, text = '<p>Hello</p>';
beforeEach(module('ui'));
beforeEach(function () {
// throw some garbage in the tinymce cfg to be sure it's getting thru to the directive
angular.module('ui.config').value('ui.config', {tinymce: {bar: 'baz'}});
});
beforeEach(inject(function (_$rootScope_, _$compile_) {
scope = _$rootScope_.$new();
$compile = _$compile_;
}));
afterEach(function () {
angular.module('ui.config').value('ui.config', {}); // cleanup
});
/**
* Asynchronously runs the compilation.
*/
function compile() {
runs(function () {
element = $compile('<form><textarea name="foo" ui-tinymce="{foo: \'bar\'}" ng-model="foo"></textarea></form>')(scope);
});
waits(1);
}
describe('compiling this directive', function () {
it('should include the passed options', function () {
spyOn($.fn, 'tinymce');
compile();
runs(function () {
expect($.fn.tinymce).toHaveBeenCalled();
expect($.fn.tinymce.mostRecentCall.args[0].foo).toEqual('bar');
});
});
it('should include the default options', function () {
spyOn($.fn, 'tinymce');
compile();
runs(function () {
expect($.fn.tinymce).toHaveBeenCalled();
expect($.fn.tinymce.mostRecentCall.args[0].bar).toEqual('baz');
});
});
});
/*
describe('setting a value to the model', function () {
it('should update the editor', function() {
compile();
runs(function () {
scope.$apply(function() {
scope.foo = text;
});
expect(element.find('textarea').tinymce().getContent()).toEqual(text);
});
});
it('should handle undefined gracefully', function() {
compile();
runs(function () {
scope.$apply(function() {
scope.foo = undefined;
});
expect(element.find('textarea').tinymce().getContent()).toEqual('');
});
});
it('should handle null gracefully', function() {
compile();
runs(function () {
scope.$apply(function() {
scope.foo = null;
});
expect(element.find('textarea').tinymce().getContent()).toEqual('');
});
});
});
describe('using the editor', function () {
it('should update the model', function() {
compile();
runs(function () {
element.find('textarea').tinymce().setContent(text);
expect($rootScope.x).toEqual(text);
});
});
});
*/
});
|