sproutcore 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +269 -0
- data/README.txt +67 -0
- data/Rakefile +4 -0
- data/app_generators/sproutcore/USAGE +5 -0
- data/app_generators/sproutcore/sproutcore_generator.rb +66 -0
- data/app_generators/sproutcore/templates/README +77 -0
- data/app_generators/sproutcore/templates/environment.yml +4 -0
- data/bin/sc-build +145 -0
- data/bin/sc-gen +24 -0
- data/bin/sc-server +63 -0
- data/bin/sproutcore +21 -0
- data/clients/sc_docs/controllers/docs.js +118 -0
- data/clients/sc_docs/core.js +19 -0
- data/clients/sc_docs/english.lproj/body.css +159 -0
- data/clients/sc_docs/english.lproj/body.rhtml +33 -0
- data/clients/sc_docs/english.lproj/controls.css +0 -0
- data/clients/sc_docs/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_docs/english.lproj/icons/small/reset.png +0 -0
- data/clients/sc_docs/english.lproj/images/gradients.png +0 -0
- data/clients/sc_docs/english.lproj/images/indicator.gif +0 -0
- data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_docs/english.lproj/no_docs.rhtml +7 -0
- data/clients/sc_docs/english.lproj/strings.js +14 -0
- data/clients/sc_docs/english.lproj/warning.rhtml +6 -0
- data/clients/sc_docs/fixtures/doc.js +11 -0
- data/clients/sc_docs/main.js +21 -0
- data/clients/sc_docs/models/doc.js +9 -0
- data/clients/sc_docs/tests/controllers/docs.rhtml +21 -0
- data/clients/sc_docs/tests/models/doc.rhtml +21 -0
- data/clients/sc_docs/tests/views/doc_frame.rhtml +21 -0
- data/clients/sc_docs/tests/views/doc_label_view.rhtml +21 -0
- data/clients/sc_docs/views/doc_frame.js +33 -0
- data/clients/sc_docs/views/doc_label.js +20 -0
- data/clients/sc_test_runner/controllers/runner.js +175 -0
- data/clients/sc_test_runner/core.js +19 -0
- data/clients/sc_test_runner/english.lproj/body.css +151 -0
- data/clients/sc_test_runner/english.lproj/body.rhtml +35 -0
- data/clients/sc_test_runner/english.lproj/controls.css +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
- data/clients/sc_test_runner/english.lproj/images/gradients.png +0 -0
- data/clients/sc_test_runner/english.lproj/images/indicator.gif +0 -0
- data/clients/sc_test_runner/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_test_runner/english.lproj/no_tests.rhtml +6 -0
- data/clients/sc_test_runner/english.lproj/strings.js +14 -0
- data/clients/sc_test_runner/english.lproj/warning.rhtml +6 -0
- data/clients/sc_test_runner/fixtures/test.js +12 -0
- data/clients/sc_test_runner/main.js +26 -0
- data/clients/sc_test_runner/models/test.js +11 -0
- data/clients/sc_test_runner/views/runner_frame.js +72 -0
- data/clients/sc_test_runner/views/test_label.js +20 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/environment.yml +9 -0
- data/frameworks/prototype/prototype.js +4186 -0
- data/frameworks/sproutcore/Core.js +378 -0
- data/frameworks/sproutcore/README +3 -0
- data/frameworks/sproutcore/controllers/array.js +236 -0
- data/frameworks/sproutcore/controllers/collection.js +305 -0
- data/frameworks/sproutcore/controllers/controller.js +323 -0
- data/frameworks/sproutcore/controllers/object.js +372 -0
- data/frameworks/sproutcore/drag/drag.js +549 -0
- data/frameworks/sproutcore/drag/drag_data_source.js +32 -0
- data/frameworks/sproutcore/drag/drag_source.js +64 -0
- data/frameworks/sproutcore/drag/drop_target.js +153 -0
- data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
- data/frameworks/sproutcore/english.lproj/buttons.css +589 -0
- data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
- data/frameworks/sproutcore/english.lproj/inline_text_editor.css +21 -0
- data/frameworks/sproutcore/english.lproj/menu.css +121 -0
- data/frameworks/sproutcore/english.lproj/panels/background-fat.jpg +0 -0
- data/frameworks/sproutcore/english.lproj/panels/background-thin.jpg +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-left-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/bottom-right-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/left-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/overlay.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/right-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-edge.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-left-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panels/top-right-corner.png +0 -0
- data/frameworks/sproutcore/english.lproj/panes.css +155 -0
- data/frameworks/sproutcore/english.lproj/picker.css +22 -0
- data/frameworks/sproutcore/english.lproj/strings.js +15 -0
- data/frameworks/sproutcore/english.lproj/tab.css +23 -0
- data/frameworks/sproutcore/english.lproj/tests.css +67 -0
- data/frameworks/sproutcore/english.lproj/theme.css +77 -0
- data/frameworks/sproutcore/foundation/animator.js +670 -0
- data/frameworks/sproutcore/foundation/application.js +199 -0
- data/frameworks/sproutcore/foundation/array.js +348 -0
- data/frameworks/sproutcore/foundation/benchmark.js +211 -0
- data/frameworks/sproutcore/foundation/binding.js +384 -0
- data/frameworks/sproutcore/foundation/date.js +357 -0
- data/frameworks/sproutcore/foundation/error.js +39 -0
- data/frameworks/sproutcore/foundation/input_manager.js +153 -0
- data/frameworks/sproutcore/foundation/json.js +296 -0
- data/frameworks/sproutcore/foundation/mock.js +42 -0
- data/frameworks/sproutcore/foundation/node_descriptor.js +56 -0
- data/frameworks/sproutcore/foundation/object.js +777 -0
- data/frameworks/sproutcore/foundation/observable.js +451 -0
- data/frameworks/sproutcore/foundation/page.js +63 -0
- data/frameworks/sproutcore/foundation/path_module.js +413 -0
- data/frameworks/sproutcore/foundation/responder.js +310 -0
- data/frameworks/sproutcore/foundation/routes.js +371 -0
- data/frameworks/sproutcore/foundation/run_loop.js +21 -0
- data/frameworks/sproutcore/foundation/server.js +491 -0
- data/frameworks/sproutcore/foundation/set.js +96 -0
- data/frameworks/sproutcore/foundation/string.js +149 -0
- data/frameworks/sproutcore/foundation/undo_manager.js +186 -0
- data/frameworks/sproutcore/foundation/unittest.js +622 -0
- data/frameworks/sproutcore/foundation/utils.js +61 -0
- data/frameworks/sproutcore/globals/panels.js +182 -0
- data/frameworks/sproutcore/globals/popups.js +60 -0
- data/frameworks/sproutcore/globals/window.js +381 -0
- data/frameworks/sproutcore/lib/index.rhtml +66 -0
- data/frameworks/sproutcore/models/collection.js +395 -0
- data/frameworks/sproutcore/models/record.js +622 -0
- data/frameworks/sproutcore/models/store.js +295 -0
- data/frameworks/sproutcore/panes/dialog.js +16 -0
- data/frameworks/sproutcore/panes/manager.js +164 -0
- data/frameworks/sproutcore/panes/menu.js +45 -0
- data/frameworks/sproutcore/panes/overlay.js +231 -0
- data/frameworks/sproutcore/panes/pane.js +90 -0
- data/frameworks/sproutcore/panes/panel.js +19 -0
- data/frameworks/sproutcore/panes/picker.js +45 -0
- data/frameworks/sproutcore/tests/controllers/array.rhtml +86 -0
- data/frameworks/sproutcore/tests/controllers/controller.rhtml +273 -0
- data/frameworks/sproutcore/tests/controllers/object.rhtml +327 -0
- data/frameworks/sproutcore/tests/foundation/application.rhtml +125 -0
- data/frameworks/sproutcore/tests/foundation/array.rhtml +221 -0
- data/frameworks/sproutcore/tests/foundation/object.rhtml +69 -0
- data/frameworks/sproutcore/tests/globals/window.rhtml +45 -0
- data/frameworks/sproutcore/tests/panes/pane.rhtml +88 -0
- data/frameworks/sproutcore/tests/views/collection.rhtml +137 -0
- data/frameworks/sproutcore/tests/views/popup_button.rhtml +115 -0
- data/frameworks/sproutcore/tests/views/text_field.rhtml +37 -0
- data/frameworks/sproutcore/validators/credit_card.js +92 -0
- data/frameworks/sproutcore/validators/date.js +36 -0
- data/frameworks/sproutcore/validators/email.js +29 -0
- data/frameworks/sproutcore/validators/not_empty.js +24 -0
- data/frameworks/sproutcore/validators/number.js +55 -0
- data/frameworks/sproutcore/validators/password.js +78 -0
- data/frameworks/sproutcore/validators/validator.js +304 -0
- data/frameworks/sproutcore/views/button.js +425 -0
- data/frameworks/sproutcore/views/checkbox_field.js +30 -0
- data/frameworks/sproutcore/views/collection.js +1521 -0
- data/frameworks/sproutcore/views/container.js +62 -0
- data/frameworks/sproutcore/views/error_explanation.js +45 -0
- data/frameworks/sproutcore/views/field.js +214 -0
- data/frameworks/sproutcore/views/filter_button.js +29 -0
- data/frameworks/sproutcore/views/form.js +591 -0
- data/frameworks/sproutcore/views/image.js +141 -0
- data/frameworks/sproutcore/views/inline_text_editor.js +96 -0
- data/frameworks/sproutcore/views/label.js +176 -0
- data/frameworks/sproutcore/views/menu_item.js +90 -0
- data/frameworks/sproutcore/views/pagination.js +54 -0
- data/frameworks/sproutcore/views/popup_button.js +86 -0
- data/frameworks/sproutcore/views/popup_menu.js +137 -0
- data/frameworks/sproutcore/views/progress.js +100 -0
- data/frameworks/sproutcore/views/radio_field.js +107 -0
- data/frameworks/sproutcore/views/radio_group.js +48 -0
- data/frameworks/sproutcore/views/segmented.js +80 -0
- data/frameworks/sproutcore/views/select_field.js +272 -0
- data/frameworks/sproutcore/views/spinner.js +11 -0
- data/frameworks/sproutcore/views/tab.js +126 -0
- data/frameworks/sproutcore/views/text_field.js +179 -0
- data/frameworks/sproutcore/views/textarea_field.js +14 -0
- data/frameworks/sproutcore/views/toolbar.js +29 -0
- data/frameworks/sproutcore/views/view.js +1389 -0
- data/frameworks/sproutcore/views/workspace.js +170 -0
- data/generators/client/README +3 -0
- data/generators/client/USAGE +12 -0
- data/generators/client/client_generator.rb +53 -0
- data/generators/client/templates/core.js +19 -0
- data/generators/client/templates/english.lproj/body.css +0 -0
- data/generators/client/templates/english.lproj/body.rhtml +3 -0
- data/generators/client/templates/english.lproj/controls.css +0 -0
- data/generators/client/templates/english.lproj/strings.js +14 -0
- data/generators/client/templates/main.js +37 -0
- data/generators/controller/USAGE +16 -0
- data/generators/controller/controller_generator.rb +51 -0
- data/generators/controller/templates/controller.js +21 -0
- data/generators/controller/templates/test.rhtml +21 -0
- data/generators/framework/README +7 -0
- data/generators/framework/USAGE +12 -0
- data/generators/framework/framework_generator.rb +53 -0
- data/generators/framework/templates/core.js +20 -0
- data/generators/framework/templates/english.lproj/body.css +0 -0
- data/generators/framework/templates/english.lproj/body.rhtml +3 -0
- data/generators/framework/templates/english.lproj/controls.css +0 -0
- data/generators/framework/templates/english.lproj/strings.js +14 -0
- data/generators/language/USAGE +16 -0
- data/generators/language/language_generator.rb +47 -0
- data/generators/language/templates/strings.js +10 -0
- data/generators/model/USAGE +24 -0
- data/generators/model/model_generator.rb +55 -0
- data/generators/model/templates/fixture.js +11 -0
- data/generators/model/templates/model.js +20 -0
- data/generators/model/templates/test.rhtml +21 -0
- data/generators/test/USAGE +16 -0
- data/generators/test/templates/test.rhtml +21 -0
- data/generators/test/test_generator.rb +47 -0
- data/generators/view/USAGE +16 -0
- data/generators/view/templates/test.rhtml +21 -0
- data/generators/view/templates/view.js +20 -0
- data/generators/view/view_generator.rb +51 -0
- data/jsdoc/README.txt +119 -0
- data/jsdoc/app/DocFile.js +137 -0
- data/jsdoc/app/DocTag.js +110 -0
- data/jsdoc/app/Doclet.js +63 -0
- data/jsdoc/app/Dumper.js +143 -0
- data/jsdoc/app/JsDoc.js +103 -0
- data/jsdoc/app/JsHilite.js +45 -0
- data/jsdoc/app/JsIO.js +163 -0
- data/jsdoc/app/JsParse.js +385 -0
- data/jsdoc/app/JsPlate.js +130 -0
- data/jsdoc/app/JsTestrun.js +129 -0
- data/jsdoc/app/JsToke.js +564 -0
- data/jsdoc/app/Symbol.js +298 -0
- data/jsdoc/app/Transformer.js +14 -0
- data/jsdoc/app/Util.js +97 -0
- data/jsdoc/app/js.jar +0 -0
- data/jsdoc/app/run.js +144 -0
- data/jsdoc/plugins/min.js +316 -0
- data/jsdoc/plugins/strip.js +20 -0
- data/jsdoc/templates/sproutcore/class.tmpl +438 -0
- data/jsdoc/templates/sproutcore/default.css +241 -0
- data/jsdoc/templates/sproutcore/index.html +13 -0
- data/jsdoc/templates/sproutcore/index.tmpl +21 -0
- data/jsdoc/templates/sproutcore/prototype.js +4186 -0
- data/jsdoc/templates/sproutcore/publish.js +236 -0
- data/jsdoc/templates/sproutcore/splash.html +7 -0
- data/lib/sproutcore/build_tools/html_builder.rb +88 -0
- data/lib/sproutcore/build_tools/resource_builder.rb +194 -0
- data/lib/sproutcore/build_tools.rb +44 -0
- data/lib/sproutcore/bundle.rb +517 -0
- data/lib/sproutcore/bundle_manifest.rb +397 -0
- data/lib/sproutcore/generator_helper.rb +170 -0
- data/lib/sproutcore/helpers/capture_helper.rb +42 -0
- data/lib/sproutcore/helpers/static_helper.rb +80 -0
- data/lib/sproutcore/helpers/tag_helper.rb +110 -0
- data/lib/sproutcore/helpers/text_helper.rb +336 -0
- data/lib/sproutcore/helpers.rb +3 -0
- data/lib/sproutcore/jsdoc.rb +40 -0
- data/lib/sproutcore/jsmin.rb +247 -0
- data/lib/sproutcore/library.rb +258 -0
- data/lib/sproutcore/merb/bundle_controller.rb +179 -0
- data/lib/sproutcore/merb/router.rb +43 -0
- data/lib/sproutcore/merb.rb +27 -0
- data/lib/sproutcore/version.rb +9 -0
- data/lib/sproutcore/view_helpers/button_views.rb +302 -0
- data/lib/sproutcore/view_helpers/core_views.rb +284 -0
- data/lib/sproutcore/view_helpers/form_views.rb +258 -0
- data/lib/sproutcore/view_helpers/menu_views.rb +94 -0
- data/lib/sproutcore/view_helpers.rb +628 -0
- data/lib/sproutcore.rb +30 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/sproutcore_spec.rb +11 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +17 -0
- metadata +365 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
<% popup_menu_view :a_menu, :pane => 'menu', :class => 'menu' do %>
|
2
|
+
<%= menu_item_view :item_enabled_key_equiv_no_target,
|
3
|
+
:outlet => true,
|
4
|
+
:label => "",
|
5
|
+
:action => "onAltShiftA",
|
6
|
+
:key_equivalent => 'alt_shift_a'
|
7
|
+
%>
|
8
|
+
<%= menu_item_view :item_enabled_key_equiv_with_target,
|
9
|
+
:outlet => true,
|
10
|
+
:label => "",
|
11
|
+
:action => "onAltShiftB",
|
12
|
+
:target => "SC.exampleController",
|
13
|
+
:key_equivalent => 'alt_shift_b'
|
14
|
+
%>
|
15
|
+
<%= menu_item_view :item_disabled_key_equiv,
|
16
|
+
:outlet => true,
|
17
|
+
:label => "",
|
18
|
+
:enabled => false,
|
19
|
+
:action => "onAltShiftB",
|
20
|
+
:key_equivalent => 'alt_shift_b'
|
21
|
+
%>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<% view :view_1 do %>
|
25
|
+
<% view :view_1_1, :outlet => true do %>
|
26
|
+
<% view :view_1_1_1, :outlet => true do %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
<% view :view_1_2, :outlet => true do %>
|
30
|
+
<% view :view_1_2_1, :outlet => true do %>
|
31
|
+
<% end %>
|
32
|
+
<% end %>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
|
36
|
+
<% content_for('final') do %>
|
37
|
+
<script>
|
38
|
+
|
39
|
+
Test.context("SC.Application", {
|
40
|
+
|
41
|
+
"Should be instantiated and placed in SC.app on page load": function()
|
42
|
+
{
|
43
|
+
SC.app.kindOf(SC.Application).shouldEqual(true);
|
44
|
+
},
|
45
|
+
"SC.app keyPane should be set to SC.window by default": function()
|
46
|
+
{
|
47
|
+
var keyPane = SC.app.get('keyPane');
|
48
|
+
( keyPane == SC.window ).shouldEqual(true);
|
49
|
+
},
|
50
|
+
"SC.app mainPane should be set to SC.window by default": function()
|
51
|
+
{
|
52
|
+
var mainPane = SC.app.get('mainPane');
|
53
|
+
( mainPane == SC.window ).shouldEqual(true);
|
54
|
+
},
|
55
|
+
"Setting the keyPane shouldn't change the mainPane": function()
|
56
|
+
{
|
57
|
+
( SC.app.get('mainPane') == SC.window ).shouldEqual(true);
|
58
|
+
|
59
|
+
var pane = SC.PaneView.viewFor(null);
|
60
|
+
SC.app.set('keyPane', pane);
|
61
|
+
( SC.app.get('mainPane') == SC.window ).shouldEqual(true);
|
62
|
+
},
|
63
|
+
|
64
|
+
setup: function()
|
65
|
+
{
|
66
|
+
},
|
67
|
+
teardown: function()
|
68
|
+
{
|
69
|
+
}
|
70
|
+
|
71
|
+
});
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
Test.context("SC.Application's sendAction method", {
|
76
|
+
|
77
|
+
"Should not handle actions that are not strings": function()
|
78
|
+
{
|
79
|
+
SC.app.sendAction( null, null, null ).shouldEqual(false);
|
80
|
+
SC.app.sendAction( false, null, null ).shouldEqual(false);
|
81
|
+
SC.app.sendAction( {}, null, null ).shouldEqual(false);
|
82
|
+
SC.app.sendAction( function(){}, null, null ).shouldEqual(false);
|
83
|
+
},
|
84
|
+
"Should return boolean for whether an action is handled": function()
|
85
|
+
{
|
86
|
+
var leaf1 = SC.page.get('view1').view11.view111;
|
87
|
+
|
88
|
+
leaf1.anActionThatReturnsNothing = this.anActionThatReturnsNothing;
|
89
|
+
leaf1.anActionThatReturnsTrue = this.anActionThatReturnsTrue;
|
90
|
+
leaf1.anActionThatReturnsFalse = this.anActionThatReturnsFalse;
|
91
|
+
leaf1.becomeFirstResponder();
|
92
|
+
|
93
|
+
SC.app.sendAction( "anActionThatReturnsNothing", leaf1, null ).shouldEqual(true);
|
94
|
+
SC.app.sendAction( "anActionThatReturnsTrue", leaf1, null ).shouldEqual(true);
|
95
|
+
|
96
|
+
SC.app.sendAction( "anActionThatReturnsFalse", leaf1, null ).shouldEqual(false);
|
97
|
+
SC.app.sendAction( "anActionThatDoesNotExist", leaf1, null ).shouldEqual(false);
|
98
|
+
},
|
99
|
+
"Should ...": function()
|
100
|
+
{
|
101
|
+
var leaf1 = SC.page.get('view1').view11.view111;
|
102
|
+
var leaf2 = SC.page.get('view1').view12.view121;
|
103
|
+
|
104
|
+
leaf1.bubblingAction = this.anActionThatReturnsNothing;
|
105
|
+
leaf2.bubblingAction = this.anActionThatReturnsNothing;
|
106
|
+
|
107
|
+
leaf1.becomeFirstResponder();
|
108
|
+
},
|
109
|
+
|
110
|
+
setup: function()
|
111
|
+
{
|
112
|
+
this.anActionThatReturnsNothing = function() { this.__action_called__ = true; };
|
113
|
+
this.anActionThatReturnsTrue = function() { this.__action_called__ = true; return true; };
|
114
|
+
this.anActionThatReturnsFalse = function() { this.__action_called__ = true; return false; };
|
115
|
+
SC.page.awake();
|
116
|
+
},
|
117
|
+
teardown: function()
|
118
|
+
{
|
119
|
+
}
|
120
|
+
|
121
|
+
});
|
122
|
+
|
123
|
+
|
124
|
+
</script>
|
125
|
+
<% end %>
|
@@ -0,0 +1,221 @@
|
|
1
|
+
<% # ========================================================================
|
2
|
+
# Array Unit Test
|
3
|
+
# ========================================================================
|
4
|
+
%>
|
5
|
+
<% content_for('final') do %>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
|
9
|
+
// This is a generic set of tests. To apply these, create a new contact, and
|
10
|
+
// call this function passing in a factory function to build your element.
|
11
|
+
ArrayTests = function(factoryFunc) {
|
12
|
+
return {
|
13
|
+
|
14
|
+
setup: function() {
|
15
|
+
this.a = factoryFunc() ;
|
16
|
+
|
17
|
+
// this will record observed changes.
|
18
|
+
var that = this ;
|
19
|
+
this.observer = function(target, key, value) {
|
20
|
+
that.notified[key] = true ;
|
21
|
+
that.notifiedValue[key] = value ;
|
22
|
+
}.bind(this) ;
|
23
|
+
|
24
|
+
this.resetObservers = function() {
|
25
|
+
this.notified = {} ;
|
26
|
+
this.notifiedValue = {} ;
|
27
|
+
} ;
|
28
|
+
|
29
|
+
this.observe = function() {
|
30
|
+
var keys = $A(arguments) ;
|
31
|
+
var loc = keys.length ;
|
32
|
+
while(--loc >= 0) {
|
33
|
+
this.a.addObserver(keys[loc], this.observer) ;
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
this.didNotify = function(key) {
|
38
|
+
return this.notified[key] == true ;
|
39
|
+
} ;
|
40
|
+
|
41
|
+
this.resetObservers() ;
|
42
|
+
},
|
43
|
+
|
44
|
+
"[].replace(0,0,'X') => ['X'] + notify": function() {
|
45
|
+
this.observe('[]') ;
|
46
|
+
this.a.replace(0,0,['X']) ;
|
47
|
+
|
48
|
+
this.a.length.shouldEqual(1) ;
|
49
|
+
this.a.objectAt(0).shouldEqual('X') ;
|
50
|
+
this.didNotify('[]').shouldEqual(YES) ;
|
51
|
+
},
|
52
|
+
|
53
|
+
"[A,B,C,D].replace(1,2,X) => [A,X,D] + notify": function() {
|
54
|
+
this.a.replace(0,0, $w('A B C D')) ;
|
55
|
+
this.observe('[]') ;
|
56
|
+
|
57
|
+
this.a.replace(1,2,['X']) ;
|
58
|
+
|
59
|
+
this.a.get('length').shouldEqual(3) ;
|
60
|
+
this.a.objectAt(0).shouldEqual('A') ;
|
61
|
+
this.a.objectAt(1).shouldEqual('X') ;
|
62
|
+
this.a.objectAt(2).shouldEqual('D') ;
|
63
|
+
this.didNotify("[]").shouldEqual(YES) ;
|
64
|
+
},
|
65
|
+
|
66
|
+
"[A,B,C,D].replace(1,2,[X,Y]) => [A,X,Y,D] + notify": function() {
|
67
|
+
this.a.replace(0,0, $w('A B C D')) ;
|
68
|
+
this.observe('[]') ;
|
69
|
+
|
70
|
+
this.a.replace(1,2, $w('X Y')) ;
|
71
|
+
|
72
|
+
this.a.get('length').shouldEqual(4) ;
|
73
|
+
this.a.objectAt(0).shouldEqual('A') ;
|
74
|
+
this.a.objectAt(1).shouldEqual('X') ;
|
75
|
+
this.a.objectAt(2).shouldEqual('Y') ;
|
76
|
+
this.a.objectAt(3).shouldEqual('D') ;
|
77
|
+
this.didNotify("[]").shouldEqual(YES) ;
|
78
|
+
},
|
79
|
+
|
80
|
+
"[A,B].replace(1,0,[X,Y]) => [A,X,Y,B] + notify": function() {
|
81
|
+
this.a.replace(0,0, $w('A B')) ;
|
82
|
+
this.observe('[]') ;
|
83
|
+
|
84
|
+
this.a.replace(1,0, $w('X Y')) ;
|
85
|
+
|
86
|
+
this.a.get('length').shouldEqual(4) ;
|
87
|
+
this.a.objectAt(0).shouldEqual('A') ;
|
88
|
+
this.a.objectAt(1).shouldEqual('X') ;
|
89
|
+
this.a.objectAt(2).shouldEqual('Y') ;
|
90
|
+
this.a.objectAt(3).shouldEqual('B') ;
|
91
|
+
this.didNotify("[]").shouldEqual(YES) ;
|
92
|
+
},
|
93
|
+
|
94
|
+
"[A,B,C,D].replace(2,2) => [A,B] + notify": function() {
|
95
|
+
this.a.replace(0,0, $w('A B C D')) ;
|
96
|
+
this.observe('[]') ;
|
97
|
+
|
98
|
+
this.a.replace(2,2) ;
|
99
|
+
|
100
|
+
this.a.get('length').shouldEqual(2) ;
|
101
|
+
this.a.objectAt(0).shouldEqual('A') ;
|
102
|
+
this.a.objectAt(1).shouldEqual('B') ;
|
103
|
+
this.didNotify("[]").shouldEqual(YES) ;
|
104
|
+
},
|
105
|
+
|
106
|
+
"[].insertAt(0,X) => [X] + notify": function() {
|
107
|
+
this.observe('[]') ;
|
108
|
+
this.a.insertAt(0,['X']) ;
|
109
|
+
this.a.get('length').shouldEqual(1) ;
|
110
|
+
this.a.objectAt(0).shouldEqual('X') ;
|
111
|
+
this.didNotify("[]").shouldEqual(YES) ;
|
112
|
+
},
|
113
|
+
|
114
|
+
"[].removeObject(obj) should remove regardless of index position": function()
|
115
|
+
{
|
116
|
+
// spec for bug in Rev:402 where removeObject was skipping index 0 when scanning the array
|
117
|
+
this.a.set('[]', $w('A B C'));
|
118
|
+
this.a.get('length').shouldEqual(3);
|
119
|
+
|
120
|
+
this.a.removeObject('C');
|
121
|
+
this.a.get('length').shouldEqual(2);
|
122
|
+
this.a.removeObject('B');
|
123
|
+
this.a.get('length').shouldEqual(1);
|
124
|
+
this.a.removeObject('A');
|
125
|
+
this.a.get('length').shouldEqual(0);
|
126
|
+
},
|
127
|
+
|
128
|
+
|
129
|
+
"[].objectAt(0) => undefined": function()
|
130
|
+
{
|
131
|
+
this.a.get('length').shouldEqual(0);
|
132
|
+
(this.a.objectAt(0) === undefined).shouldEqual(YES);
|
133
|
+
},
|
134
|
+
"[A,B,C].objectAt(5) => undefined": function()
|
135
|
+
{
|
136
|
+
this.a.get('length').shouldEqual(0);
|
137
|
+
this.a.set('[]', $w('A B C')) ;
|
138
|
+
this.a.get('length').shouldEqual(3) ;
|
139
|
+
this.a.objectAt(0).shouldEqual('A');
|
140
|
+
(this.a.objectAt(5) === undefined).shouldEqual(YES);
|
141
|
+
},
|
142
|
+
|
143
|
+
"[A,B,C].set('[]',[X,Y]) => [X,Y] + notify": function() {
|
144
|
+
this.a.replace(0,0, $w('A B C')) ;
|
145
|
+
this.observe('[]') ;
|
146
|
+
|
147
|
+
this.a.set('[]', $w('X Y')) ;
|
148
|
+
|
149
|
+
this.a.get('length').shouldEqual(2) ;
|
150
|
+
this.a.objectAt(0).shouldEqual('X') ;
|
151
|
+
this.a.objectAt(1).shouldEqual('Y') ;
|
152
|
+
this.didNotify('[]').shouldEqual(YES) ;
|
153
|
+
},
|
154
|
+
|
155
|
+
"[A,B,C] should be Enumerable": function() {
|
156
|
+
this.a.replace(0, 0, $w('A B C')) ;
|
157
|
+
|
158
|
+
var cnt = 0 ;
|
159
|
+
var items = [] ;
|
160
|
+
this.a.each(function( item, idx ) {
|
161
|
+
items.push(item) ;
|
162
|
+
cnt++ ;
|
163
|
+
}) ;
|
164
|
+
|
165
|
+
items[0].shouldEqual('A') ;
|
166
|
+
items[1].shouldEqual('B') ;
|
167
|
+
items[2].shouldEqual('C') ;
|
168
|
+
cnt.shouldEqual(this.a.get('length')) ;
|
169
|
+
},
|
170
|
+
|
171
|
+
"ary.isEqual() should return true when array contents match": function() {
|
172
|
+
this.a.replace(0,0, $w('A B C')) ;
|
173
|
+
|
174
|
+
var ary = $w('A B C') ; // test against a different object.
|
175
|
+
this.a.isEqual(ary).shouldEqual(true) ;
|
176
|
+
|
177
|
+
ary = $w('A B') ;
|
178
|
+
this.a.isEqual(ary).shouldEqual(false) ;
|
179
|
+
|
180
|
+
ary = $w('X Y Z') ;
|
181
|
+
this.a.isEqual(ary).shouldEqual(false) ;
|
182
|
+
|
183
|
+
this.a.isEqual(this.a).shouldEqual(true) ;
|
184
|
+
}
|
185
|
+
} ;
|
186
|
+
} ;
|
187
|
+
|
188
|
+
// Test the SproutCore Array interface on native arrays.
|
189
|
+
Test.context("SC.Array", ArrayTests(function() { return []; })) ;
|
190
|
+
|
191
|
+
// Test the SproutCore Array interface on a custom object.
|
192
|
+
DummyArray = SC.Object.extend(SC.Array, {
|
193
|
+
|
194
|
+
length: 0,
|
195
|
+
|
196
|
+
content: null,
|
197
|
+
|
198
|
+
replace: function(idx, amt, objects) {
|
199
|
+
if (!this.content) this.content = [] ;
|
200
|
+
|
201
|
+
this.beginPropertyChanges() ;
|
202
|
+
this.content.replace(idx,amt,objects) ;
|
203
|
+
|
204
|
+
this.set('length', this.content.length) ;
|
205
|
+
this.arrayContentDidChange() ;
|
206
|
+
this.endPropertyChanges() ;
|
207
|
+
},
|
208
|
+
|
209
|
+
objectAt: function(idx) {
|
210
|
+
if (!this.content) this.content = [] ;
|
211
|
+
return this.content[idx] ;
|
212
|
+
}
|
213
|
+
}) ;
|
214
|
+
|
215
|
+
Test.context("DummyArray", ArrayTests(function() {
|
216
|
+
return DummyArray.create() ;
|
217
|
+
}));
|
218
|
+
|
219
|
+
</script>
|
220
|
+
|
221
|
+
<% end %>
|
@@ -0,0 +1,69 @@
|
|
1
|
+
<% content_for('final') do %>
|
2
|
+
<script>
|
3
|
+
|
4
|
+
Test.context("A new SC.Object instance", {
|
5
|
+
|
6
|
+
setup: function()
|
7
|
+
{
|
8
|
+
this.obj = SC.Object.create({
|
9
|
+
foo: "bar",
|
10
|
+
total: 12345,
|
11
|
+
aMethodThatExists: function() {},
|
12
|
+
aMethodThatReturnsTrue: function() { return true; },
|
13
|
+
aMethodThatReturnsFoobar: function() { return "Foobar"; }
|
14
|
+
});
|
15
|
+
},
|
16
|
+
teardown: function()
|
17
|
+
{
|
18
|
+
delete this.obj;
|
19
|
+
},
|
20
|
+
|
21
|
+
"Should identify it's methods using the 'respondsTo' method": function()
|
22
|
+
{
|
23
|
+
this.obj.respondsTo('aMethodThatExists').shouldEqual(true);
|
24
|
+
this.obj.respondsTo('aMethodThatDoesNotExist').shouldEqual(false);
|
25
|
+
},
|
26
|
+
"Should return false when asked to perform a method it does not have": function()
|
27
|
+
{
|
28
|
+
this.obj.tryToPerform('aMethodThatDoesNotExist').shouldEqual(false);
|
29
|
+
},
|
30
|
+
"Should pass back the return value of a method it was asked to perform": function()
|
31
|
+
{
|
32
|
+
this.obj.tryToPerform('aMethodThatReturnsTrue').shouldEqual(true);
|
33
|
+
this.obj.tryToPerform('aMethodThatReturnsFoobar').shouldEqual("Foobar");
|
34
|
+
},
|
35
|
+
|
36
|
+
"Should return it's properties when requested using SC.Object#get": function()
|
37
|
+
{
|
38
|
+
this.obj.get('foo').shouldEqual('bar');
|
39
|
+
this.obj.get('total').shouldEqual(12345);
|
40
|
+
},
|
41
|
+
"Should allow changing of those properties by calling SC.Object#set": function()
|
42
|
+
{
|
43
|
+
this.obj.get('foo').shouldEqual('bar');
|
44
|
+
this.obj.get('total').shouldEqual(12345);
|
45
|
+
|
46
|
+
this.obj.set( 'foo', 'Chunky Bacon' );
|
47
|
+
this.obj.set( 'total', 12 );
|
48
|
+
|
49
|
+
this.obj.get('foo').shouldEqual('Chunky Bacon');
|
50
|
+
this.obj.get('total').shouldEqual(12);
|
51
|
+
},
|
52
|
+
"Should only advertise changes once per request to SC.Object#didChangeFor": function()
|
53
|
+
{
|
54
|
+
this.obj.set( 'foo', 'Chunky Bacon' );
|
55
|
+
this.obj.didChangeFor( this, 'foo' ).shouldEqual(true);
|
56
|
+
this.obj.didChangeFor( this, 'foo' ).shouldEqual(false);
|
57
|
+
},
|
58
|
+
"Should advertise changes once per request to SC.Object#didChangeFor when setting property to NULL": function()
|
59
|
+
{
|
60
|
+
this.obj.set( 'foo', null );
|
61
|
+
this.obj.didChangeFor( this, 'foo' ).shouldEqual(true);
|
62
|
+
this.obj.didChangeFor( this, 'foo' ).shouldEqual(false);
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
});
|
67
|
+
|
68
|
+
</script>
|
69
|
+
<% end %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<% content_for('final') do %>
|
2
|
+
|
3
|
+
<script type="text/javascript" charset="utf-8">
|
4
|
+
|
5
|
+
Test.context("SC.window event handlers", {
|
6
|
+
|
7
|
+
"Should stop events when handled": function()
|
8
|
+
{
|
9
|
+
var e = SC.Mock.KeyEvent.create({ type: 'keyup', keyCode: 65 });
|
10
|
+
SC.window.keyUp = function(e) { this.keyUpWasHandled = true; };
|
11
|
+
|
12
|
+
SC.window._onkeyup(e).shouldEqual(false);
|
13
|
+
SC.window.keyUpWasHandled.shouldEqual(true);
|
14
|
+
e.stopped.shouldEqual(true);
|
15
|
+
},
|
16
|
+
|
17
|
+
"Should not stop events when handler sets the event's _stopWhenHandled property to false": function()
|
18
|
+
{
|
19
|
+
var e = SC.Mock.KeyEvent.create({ type: 'keyup', keyCode: 65 });
|
20
|
+
SC.window.keyUp = function(e) { e._stopWhenHandled = false; this.keyUpWasHandled = true; };
|
21
|
+
|
22
|
+
SC.window._onkeyup(e).shouldEqual(true);
|
23
|
+
SC.window.keyUpWasHandled.shouldEqual(true);
|
24
|
+
e.stopped.shouldEqual(false);
|
25
|
+
},
|
26
|
+
|
27
|
+
"Should not stop events when the event's _stopWhenHandled property is false *before* being sent to the handler": function()
|
28
|
+
{
|
29
|
+
var e = SC.Mock.KeyEvent.create({ type: 'keyup', keyCode: 65, _stopWhenHandled: false });
|
30
|
+
SC.window.keyUp = function(e) { this.keyUpWasHandled = true; };
|
31
|
+
|
32
|
+
SC.window._onkeyup(e).shouldEqual(true);
|
33
|
+
SC.window.keyUpWasHandled.shouldEqual(true);
|
34
|
+
e.stopped.shouldEqual(false);
|
35
|
+
},
|
36
|
+
|
37
|
+
setup: function()
|
38
|
+
{
|
39
|
+
}
|
40
|
+
|
41
|
+
});
|
42
|
+
|
43
|
+
</script>
|
44
|
+
|
45
|
+
<% end %>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
<% content_for('final') do %>
|
2
|
+
<script>
|
3
|
+
|
4
|
+
Test.context("A new SC.PaneView instance", {
|
5
|
+
|
6
|
+
"Should identify itself as a SC.Pane": function()
|
7
|
+
{
|
8
|
+
this.pane.get('isPane').shouldEqual(true);
|
9
|
+
},
|
10
|
+
"Should not have a pane of it's own": function()
|
11
|
+
{
|
12
|
+
(this.pane.get('pane') === null).shouldEqual(true);
|
13
|
+
},
|
14
|
+
|
15
|
+
"Should not be keyPane or mainPane": function()
|
16
|
+
{
|
17
|
+
this.pane.get('isKeyPane').shouldEqual(false);
|
18
|
+
this.pane.get('isMainPane').shouldEqual(false);
|
19
|
+
},
|
20
|
+
"Should allow itself to be keyPane or mainPane": function()
|
21
|
+
{
|
22
|
+
this.pane.get('canBecomeKeyPane').shouldEqual(true);
|
23
|
+
this.pane.get('canBecomeMainPane').shouldEqual(true);
|
24
|
+
},
|
25
|
+
"Should run callback methods when changing keyPane or mainPane status": function()
|
26
|
+
{
|
27
|
+
var otherPane = SC.PaneView.viewFor(null);
|
28
|
+
|
29
|
+
this.pane._didBecomeKeyPaneCalled = 0;
|
30
|
+
this.pane._willResignKeyPaneCalled = 0;
|
31
|
+
this.pane._didBecomeMainPaneCalled = 0;
|
32
|
+
this.pane._willResignMainPaneCalled = 0;
|
33
|
+
|
34
|
+
this.pane.didBecomeKeyPane = function() { this._didBecomeKeyPaneCalled++; };
|
35
|
+
this.pane.willResignKeyPane = function() { this._willResignKeyPaneCalled++; };
|
36
|
+
this.pane.didBecomeMainPane = function() { this._didBecomeMainPaneCalled++; };
|
37
|
+
this.pane.willResignMainPane = function() { this._willResignMainPaneCalled++; };
|
38
|
+
|
39
|
+
// making keyPane
|
40
|
+
this.pane._didBecomeKeyPaneCalled.shouldEqual(0);
|
41
|
+
this.pane.makeKeyPane();
|
42
|
+
this.pane._didBecomeKeyPaneCalled.shouldEqual(1);
|
43
|
+
this.pane.makeKeyPane();
|
44
|
+
this.pane._didBecomeKeyPaneCalled.shouldEqual(1);
|
45
|
+
// resigning keyPane
|
46
|
+
this.pane._willResignKeyPaneCalled.shouldEqual(0);
|
47
|
+
otherPane.makeKeyPane();
|
48
|
+
this.pane._willResignKeyPaneCalled.shouldEqual(1);
|
49
|
+
// making mainPane
|
50
|
+
this.pane._didBecomeMainPaneCalled.shouldEqual(0);
|
51
|
+
this.pane.makeMainPane();
|
52
|
+
this.pane._didBecomeMainPaneCalled.shouldEqual(1);
|
53
|
+
this.pane.makeMainPane();
|
54
|
+
this.pane._didBecomeMainPaneCalled.shouldEqual(1);
|
55
|
+
// resigning mainPane
|
56
|
+
this.pane._willResignMainPaneCalled.shouldEqual(0);
|
57
|
+
otherPane.makeMainPane();
|
58
|
+
this.pane._willResignMainPaneCalled.shouldEqual(1);
|
59
|
+
},
|
60
|
+
|
61
|
+
"Should have a null firstResponder": function()
|
62
|
+
{
|
63
|
+
(this.pane.get('firstResponder') === null).shouldEqual(true);
|
64
|
+
},
|
65
|
+
"Should have a null defaultResponder": function()
|
66
|
+
{
|
67
|
+
(this.pane.get('defaultResponder') === null).shouldEqual(true);
|
68
|
+
},
|
69
|
+
"Should flag a view as 'isFirstResponder' when setting the firstResponder property": function()
|
70
|
+
{
|
71
|
+
var view = SC.View.create();
|
72
|
+
view.get('isFirstResponder').shouldEqual(false);
|
73
|
+
this.pane.set('firstResponder', view);
|
74
|
+
view.get('isFirstResponder').shouldEqual(true);
|
75
|
+
},
|
76
|
+
|
77
|
+
setup: function()
|
78
|
+
{
|
79
|
+
this.pane = SC.PaneView.viewFor(null);
|
80
|
+
},
|
81
|
+
teardown: function()
|
82
|
+
{
|
83
|
+
delete this.pane;
|
84
|
+
}
|
85
|
+
});
|
86
|
+
|
87
|
+
</script>
|
88
|
+
<% end %>
|
@@ -0,0 +1,137 @@
|
|
1
|
+
<% content_for('final') do %>
|
2
|
+
<script>
|
3
|
+
|
4
|
+
Test.context("A SC.CollectionView with it's content set to a SC.CollectionController", {
|
5
|
+
|
6
|
+
"Should contain the same number of item views as it's controller has records": function()
|
7
|
+
{
|
8
|
+
testCollectionView.get('itemViews').length.shouldEqual(6);
|
9
|
+
},
|
10
|
+
"Should update it's item views as it's controller is updated": function()
|
11
|
+
{
|
12
|
+
testCollectionView.get('itemViews').length.shouldEqual(6);
|
13
|
+
SC.Store.addRecord( SC.Record.create({ guid: '1007', name: 'item seven' }) );
|
14
|
+
testCollectionView.get('itemViews').length.shouldEqual(7);
|
15
|
+
},
|
16
|
+
"Should scroll to the selected item": function()
|
17
|
+
{
|
18
|
+
testCollection.get('records').length.shouldEqual(6);
|
19
|
+
testCollectionView.get('rootElement').scrollTop.shouldEqual(0);
|
20
|
+
testCollectionView.scrollToItemRecord( testCollection.get('records').last() );
|
21
|
+
testCollectionView.get('rootElement').scrollTop.shouldEqual(30);
|
22
|
+
},
|
23
|
+
"Should not scroll to the selected item if it's already fully visible": function()
|
24
|
+
{
|
25
|
+
testCollection.get('records').length.shouldEqual(6);
|
26
|
+
testCollectionView.get('rootElement').scrollTop.shouldEqual(0);
|
27
|
+
testCollectionView.scrollToItemRecord( testCollection.get('records')[1] );
|
28
|
+
testCollectionView.get('rootElement').scrollTop.shouldEqual(0);
|
29
|
+
},
|
30
|
+
setup: function()
|
31
|
+
{
|
32
|
+
// create the view...
|
33
|
+
testCollectionView = SC.CollectionView.extend({
|
34
|
+
contentBinding: 'testController.arrangedObjects',
|
35
|
+
selectionBinding: 'testController.selection'
|
36
|
+
}).create();
|
37
|
+
SC.window.appendChild(testCollectionView);
|
38
|
+
|
39
|
+
// create some item data...
|
40
|
+
[
|
41
|
+
{ guid: '1001', name: 'item one' },
|
42
|
+
{ guid: '1002', name: 'item two' },
|
43
|
+
{ guid: '1003', name: 'item three' },
|
44
|
+
{ guid: '1004', name: 'item four' },
|
45
|
+
{ guid: '1005', name: 'item five' },
|
46
|
+
{ guid: '1006', name: 'item six' }
|
47
|
+
].each(function(o){ SC.Store.addRecord(SC.Record.create(o)); });
|
48
|
+
|
49
|
+
// a collection to hold the items...
|
50
|
+
testCollection = SC.Record.collection();
|
51
|
+
testCollection.refresh();
|
52
|
+
|
53
|
+
// a controller for the collection...
|
54
|
+
testController = SC.CollectionController.create();
|
55
|
+
testController.set('content', testCollection);
|
56
|
+
|
57
|
+
|
58
|
+
// make the view scrollable.
|
59
|
+
var element = Element.extend(testCollectionView.get('rootElement'));
|
60
|
+
element.setStyle({ overflow: 'auto', width: '100px', height: '30px' });
|
61
|
+
// set the item heights to force the collection to scroll
|
62
|
+
element.childElements().each(function(child)
|
63
|
+
{
|
64
|
+
child.setStyle({ height: '10px' });
|
65
|
+
});
|
66
|
+
},
|
67
|
+
teardown: function()
|
68
|
+
{
|
69
|
+
// tell SC.Store to dump all the records...
|
70
|
+
// otherwise, since SC.Store is shared across all tests (yuk!) we'll get shared fixtues
|
71
|
+
testCollection.get('records').each(function(r){ SC.Store.removeRecord(r); });
|
72
|
+
|
73
|
+
// remove the view from SC.window... again, no shared fixtures...
|
74
|
+
testCollectionView.removeFromParent();
|
75
|
+
|
76
|
+
delete testCollectionView;
|
77
|
+
delete testCollection;
|
78
|
+
delete testController;
|
79
|
+
}
|
80
|
+
|
81
|
+
});
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
Test.context("A SC.CollectionView with it's content set to a SC.ArrayController",
|
88
|
+
{
|
89
|
+
"Should contain the same number of item views as it's controller has records": function()
|
90
|
+
{
|
91
|
+
this.controller.get('length').shouldEqual(6);
|
92
|
+
this.view.get('itemViews').length.shouldEqual(6);
|
93
|
+
},
|
94
|
+
"Should update it's item views as it's controller is updated": function()
|
95
|
+
{
|
96
|
+
this.view.get('itemViews').length.shouldEqual(6);
|
97
|
+
this.controller.pushObject({ guid: '1007', name: 'item seven' });
|
98
|
+
this.view.get('itemViews').length.shouldEqual(7);
|
99
|
+
this.controller.popObject();
|
100
|
+
this.view.get('itemViews').length.shouldEqual(6);
|
101
|
+
},
|
102
|
+
setup: function()
|
103
|
+
{
|
104
|
+
// create the view...
|
105
|
+
this.view = SC.CollectionView.create();
|
106
|
+
SC.window.appendChild(this.view);
|
107
|
+
|
108
|
+
// create some item data...
|
109
|
+
this.array = [
|
110
|
+
{ guid: '1001', name: 'item one' },
|
111
|
+
{ guid: '1002', name: 'item two' },
|
112
|
+
{ guid: '1003', name: 'item three' },
|
113
|
+
{ guid: '1004', name: 'item four' },
|
114
|
+
{ guid: '1005', name: 'item five' },
|
115
|
+
{ guid: '1006', name: 'item six' }
|
116
|
+
];
|
117
|
+
|
118
|
+
this.controller = SC.ArrayController.create();
|
119
|
+
this.controller.set('content', this.array);
|
120
|
+
this.view.set('content', this.controller);
|
121
|
+
},
|
122
|
+
teardown: function()
|
123
|
+
{
|
124
|
+
// remove the view from SC.window
|
125
|
+
this.view.removeFromParent();
|
126
|
+
|
127
|
+
delete this.view;
|
128
|
+
delete this.array;
|
129
|
+
delete this.controller;
|
130
|
+
}
|
131
|
+
});
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
</script>
|
137
|
+
<% end %>
|