|
|
@@ -0,0 +1,219 @@
|
|
|
+define(["amber/boot", "require", "amber/core/SUnit"], function($boot,requirejs){"use strict";
|
|
|
+var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
|
|
|
+var $pkg = $core.addPackage("Helios-Core-Tests");
|
|
|
+$pkg.transport = {"type":"amd","amdNamespace":"helios"};
|
|
|
+
|
|
|
+$core.addClass("HLCompletionTest", $globals.TestCase, "Helios-Core-Tests");
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
+$globals.HLCompletionTest.comment="I am an abstract test of the completions a rendered widget offers in its input.";
|
|
|
+//>>excludeEnd("ide");
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "inFixtureDo:",
|
|
|
+protocol: "accessing",
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
+args: ["aBlock"],
|
|
|
+source: "inFixtureDo: aBlock\x0a\x09| fixture |\x0a\x09fixture := (HTMLCanvas onJQuery: 'body' asJQuery) div.\x0a\x09^ [ aBlock value: fixture asJQuery ]\x0a\x09\x09ensure: [ fixture asJQuery remove ]",
|
|
|
+referencedClasses: ["HTMLCanvas"],
|
|
|
+//>>excludeEnd("ide");
|
|
|
+pragmas: [],
|
|
|
+messageSends: ["div", "onJQuery:", "asJQuery", "ensure:", "value:", "remove"]
|
|
|
+}, function ($methodClass){ return function (aBlock){
|
|
|
+var self=this,$self=this;
|
|
|
+var fixture;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+fixture=$recv($recv($globals.HTMLCanvas)._onJQuery_(["body"._asJQuery()
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+,$ctx1.sendIdx["asJQuery"]=1
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+][0]))._div();
|
|
|
+return $recv((function(){
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+return $recv(aBlock)._value_([$recv(fixture)._asJQuery()
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+,$ctx2.sendIdx["asJQuery"]=2
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+][0]);
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}))._ensure_((function(){
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+return $recv($recv(fixture)._asJQuery())._remove();
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}));
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"inFixtureDo:",{aBlock:aBlock,fixture:fixture})});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}; }),
|
|
|
+$globals.HLCompletionTest);
|
|
|
+
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "suggestionsOf:for:",
|
|
|
+protocol: "accessing",
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
+args: ["aWidget", "aString"],
|
|
|
+source: "suggestionsOf: aWidget for: aString\x0a\x09^ self inFixtureDo: [ :fixture |\x0a\x09\x09| input |\x0a\x09\x09aWidget appendToJQuery: fixture.\x0a\x09\x09input := fixture find: 'input'.\x0a\x09\x09input val: aString; autocomplete: 'search'.\x0a\x09\x09(input autocomplete: 'widget') children toArray collect: [ :each | each textContent ] ]",
|
|
|
+referencedClasses: [],
|
|
|
+//>>excludeEnd("ide");
|
|
|
+pragmas: [],
|
|
|
+messageSends: ["inFixtureDo:", "appendToJQuery:", "find:", "val:", "autocomplete:", "collect:", "toArray", "children", "textContent"]
|
|
|
+}, function ($methodClass){ return function (aWidget,aString){
|
|
|
+var self=this,$self=this;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+var $1;
|
|
|
+return $self._inFixtureDo_((function(fixture){
|
|
|
+var input;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+$recv(aWidget)._appendToJQuery_(fixture);
|
|
|
+input=$recv(fixture)._find_("input");
|
|
|
+$1=input;
|
|
|
+$recv($1)._val_(aString);
|
|
|
+[$recv($1)._autocomplete_("search")
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+,$ctx2.sendIdx["autocomplete:"]=1
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+][0];
|
|
|
+return $recv($recv($recv($recv(input)._autocomplete_("widget"))._children())._toArray())._collect_((function(each){
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx3) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+return $recv(each)._textContent();
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}));
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({fixture:fixture,input:input},$ctx1,1)});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}));
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"suggestionsOf:for:",{aWidget:aWidget,aString:aString})});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}; }),
|
|
|
+$globals.HLCompletionTest);
|
|
|
+
|
|
|
+
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "isAbstract",
|
|
|
+protocol: "testing",
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
+args: [],
|
|
|
+source: "isAbstract\x0a\x09^ self name = HLCompletionTest name",
|
|
|
+referencedClasses: ["HLCompletionTest"],
|
|
|
+//>>excludeEnd("ide");
|
|
|
+pragmas: [],
|
|
|
+messageSends: ["=", "name"]
|
|
|
+}, function ($methodClass){ return function (){
|
|
|
+var self=this,$self=this;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+return $recv([$self._name()
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+,$ctx1.sendIdx["name"]=1
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+][0]).__eq($recv($globals.HLCompletionTest)._name());
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"isAbstract",{})});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}; }),
|
|
|
+$globals.HLCompletionTest.a$cls);
|
|
|
+
|
|
|
+
|
|
|
+$core.addClass("HLSpotlightWidgetTest", $globals.HLCompletionTest, "Helios-Core-Tests");
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "testOffersMatchingClassNames",
|
|
|
+protocol: "tests",
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
+args: [],
|
|
|
+source: "testOffersMatchingClassNames\x0a\x09PlatformDom isFeasible ifTrue: [\x0a\x09\x09self assert: ((self suggestionsOf: HLSpotlightWidget new for: 'HLSpotlightWid') includes: 'HLSpotlightWidget') ]",
|
|
|
+referencedClasses: ["PlatformDom", "HLSpotlightWidget"],
|
|
|
+//>>excludeEnd("ide");
|
|
|
+pragmas: [],
|
|
|
+messageSends: ["ifTrue:", "isFeasible", "assert:", "includes:", "suggestionsOf:for:", "new"]
|
|
|
+}, function ($methodClass){ return function (){
|
|
|
+var self=this,$self=this;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+if($core.assert($recv($globals.PlatformDom)._isFeasible())){
|
|
|
+$self._assert_($recv($self._suggestionsOf_for_($recv($globals.HLSpotlightWidget)._new(),"HLSpotlightWid"))._includes_("HLSpotlightWidget"));
|
|
|
+}
|
|
|
+return self;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"testOffersMatchingClassNames",{})});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}; }),
|
|
|
+$globals.HLSpotlightWidgetTest);
|
|
|
+
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "testRefreshKeepsOneCompletionMenu",
|
|
|
+protocol: "tests",
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
+args: [],
|
|
|
+source: "testRefreshKeepsOneCompletionMenu\x0a\x09PlatformDom isFeasible ifTrue: [\x0a\x09\x09| spotlight menus |\x0a\x09\x09spotlight := HLSpotlightWidget new.\x0a\x09\x09menus := [ '.ui-autocomplete' asJQuery length ].\x0a\x09\x09self inFixtureDo: [ :fixture |\x0a\x09\x09\x09| rendered |\x0a\x09\x09\x09spotlight appendToJQuery: fixture.\x0a\x09\x09\x09rendered := menus value.\x0a\x09\x09\x09spotlight refresh.\x0a\x09\x09\x09self assert: menus value equals: rendered ] ]",
|
|
|
+referencedClasses: ["PlatformDom", "HLSpotlightWidget"],
|
|
|
+//>>excludeEnd("ide");
|
|
|
+pragmas: [],
|
|
|
+messageSends: ["ifTrue:", "isFeasible", "new", "length", "asJQuery", "inFixtureDo:", "appendToJQuery:", "value", "refresh", "assert:equals:"]
|
|
|
+}, function ($methodClass){ return function (){
|
|
|
+var self=this,$self=this;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+if($core.assert($recv($globals.PlatformDom)._isFeasible())){
|
|
|
+var spotlight,menus;
|
|
|
+spotlight=$recv($globals.HLSpotlightWidget)._new();
|
|
|
+menus=(function(){
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+return $recv(".ui-autocomplete"._asJQuery())._length();
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+});
|
|
|
+$self._inFixtureDo_((function(fixture){
|
|
|
+var rendered;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+$recv(spotlight)._appendToJQuery_(fixture);
|
|
|
+rendered=[$recv(menus)._value()
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+,$ctx2.sendIdx["value"]=1
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+][0];
|
|
|
+$recv(spotlight)._refresh();
|
|
|
+return $self._assert_equals_($recv(menus)._value(),rendered);
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({fixture:fixture,rendered:rendered},$ctx1,3)});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}));
|
|
|
+}
|
|
|
+return self;
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"testRefreshKeepsOneCompletionMenu",{})});
|
|
|
+//>>excludeEnd("ctx");
|
|
|
+}; }),
|
|
|
+$globals.HLSpotlightWidgetTest);
|
|
|
+
|
|
|
+
|
|
|
+});
|