aboutsummaryrefslogtreecommitdiffstats
path: root/test/WidgetsTest.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/WidgetsTest.js')
-rw-r--r--test/WidgetsTest.js99
1 files changed, 49 insertions, 50 deletions
diff --git a/test/WidgetsTest.js b/test/WidgetsTest.js
index a245abda..c0a2d082 100644
--- a/test/WidgetsTest.js
+++ b/test/WidgetsTest.js
@@ -2,8 +2,8 @@ WidgetTest = TestCase('WidgetTest');
WidgetTest.prototype.testRequired = function () {
var view = $('<input name="a" ng-required>');
- var scope = new nglr.Scope({$invalidWidgets:[]});
- var cntl = new nglr.TextController(view[0], 'a');
+ var scope = new Scope({$invalidWidgets:[]});
+ var cntl = new TextController(view[0], 'a');
cntl.updateView(scope);
assertTrue(view.hasClass('ng-validation-error'));
assertEquals("Required Value", view.attr('ng-error'));
@@ -15,8 +15,8 @@ WidgetTest.prototype.testRequired = function () {
WidgetTest.prototype.testValidator = function () {
var view = $('<input name="a" ng-validate="testValidator:\'ABC\'">');
- var scope = new nglr.Scope({$invalidWidgets:[]});
- var cntl = new nglr.TextController(view[0], 'a');
+ var scope = new Scope({$invalidWidgets:[]});
+ var cntl = new TextController(view[0], 'a');
angular.validator.testValidator = function(value, expect){
return value == expect ? null : "Error text";
};
@@ -43,8 +43,8 @@ WidgetTest.prototype.testValidator = function () {
WidgetTest.prototype.testRequiredValidator = function () {
var view = $('<input name="a" ng-required ng-validate="testValidator:\'ABC\'">');
- var scope = new nglr.Scope({$invalidWidgets:[]});
- var cntl = new nglr.TextController(view[0], 'a');
+ var scope = new Scope({$invalidWidgets:[]});
+ var cntl = new TextController(view[0], 'a');
angular.validator.testValidator = function(value, expect){
return value == expect ? null : "Error text";
};
@@ -67,29 +67,29 @@ WidgetTest.prototype.testRequiredValidator = function () {
delete angular.validator['testValidator'];
};
-TextController = TestCase("TextController");
+TextControllerTest = TestCase("TextControllerTest");
-TextController.prototype.testDatePicker = function() {
+TextControllerTest.prototype.testDatePicker = function() {
var input = $('<input type="text" ng-widget="datepicker">');
- input.data('scope', new nglr.Scope());
+ input.data('scope', new Scope());
var body = $(document.body);
body.append(input);
- var binder = new nglr.Binder(input[0], new nglr.WidgetFactory());
+ var binder = new Binder(input[0], new WidgetFactory());
assertTrue('before', input.data('datepicker') === undefined);
binder.compile();
assertTrue('after', input.data('datepicker') !== null);
assertTrue(body.html(), input.hasClass('hasDatepicker'));
};
-RepeaterUpdater = TestCase("RepeaterUpdater");
+RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest");
-RepeaterUpdater.prototype.testRemoveThenAdd = function() {
+RepeaterUpdaterTest.prototype.testRemoveThenAdd = function() {
var view = $("<div><span/></div>");
var template = function () {
return $("<li/>");
};
- var repeater = new nglr.RepeaterUpdater(view.find("span"), "a in b", template, "");
- var scope = new nglr.Scope();
+ var repeater = new RepeaterUpdater(view.find("span"), "a in b", template, "");
+ var scope = new Scope();
scope.set('b', [1,2]);
repeater.updateView(scope);
@@ -102,14 +102,14 @@ RepeaterUpdater.prototype.testRemoveThenAdd = function() {
assertEquals(1, view.find("li").size());
};
-RepeaterUpdater.prototype.testShouldBindWidgetOnRepeaterClone = function(){
+RepeaterUpdaterTest.prototype.testShouldBindWidgetOnRepeaterClone = function(){
//fail();
};
-RepeaterUpdater.prototype.testShouldThrowInformativeSyntaxError= function(){
+RepeaterUpdaterTest.prototype.testShouldThrowInformativeSyntaxError= function(){
expectAsserts(1);
try {
- var repeater = new nglr.RepeaterUpdater(null, "a=b");
+ var repeater = new RepeaterUpdater(null, "a=b");
} catch (e) {
assertEquals("Expected ng-repeat in form of 'item in collection' but got 'a=b'.", e);
}
@@ -118,17 +118,17 @@ RepeaterUpdater.prototype.testShouldThrowInformativeSyntaxError= function(){
SelectControllerTest = TestCase("SelectControllerTest");
SelectControllerTest.prototype.testShouldUpdateModelNullOnNothingSelected = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
var view = {selectedIndex:-1, options:[]};
- var cntl = new nglr.SelectController(view, 'abc');
+ var cntl = new SelectController(view, 'abc');
cntl.updateModel(scope);
assertNull(scope.get('abc'));
};
SelectControllerTest.prototype.testShouldUpdateModelWhenNothingSelected = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
var view = {value:'123'};
- var cntl = new nglr.SelectController(view, 'abc');
+ var cntl = new SelectController(view, 'abc');
cntl.updateView(scope);
assertEquals("123", scope.get('abc'));
};
@@ -137,8 +137,8 @@ BindUpdaterTest = TestCase("BindUpdaterTest");
BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () {
var view = $('<span />');
- var controller = new nglr.BindUpdater(view[0], "{{a}}");
- var scope = new nglr.Scope();
+ var controller = new BindUpdater(view[0], "{{a}}");
+ var scope = new Scope();
scope.set('a', undefined);
controller.updateView(scope);
@@ -151,20 +151,20 @@ BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () {
BindUpdaterTest.prototype.testShouldDisplayJsonForNonStrings = function () {
var view = $('<span />');
- var controller = new nglr.BindUpdater(view[0], "{{obj}}");
+ var controller = new BindUpdater(view[0], "{{obj}}");
- controller.updateView(new nglr.Scope({obj:[]}));
+ controller.updateView(new Scope({obj:[]}));
assertEquals("[]", view.text());
- controller.updateView(new nglr.Scope({obj:{text:'abc'}}));
- assertEquals('abc', nglr.fromJson(view.text()).text);
+ controller.updateView(new Scope({obj:{text:'abc'}}));
+ assertEquals('abc', fromJson(view.text()).text);
};
BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () {
var view = $('<span />');
- var controller = new nglr.BindUpdater(view[0], "<fake>&{{obj}}</fake>");
- var scope = new nglr.Scope();
+ var controller = new BindUpdater(view[0], "<fake>&{{obj}}</fake>");
+ var scope = new Scope();
scope.set("obj", $('<div>myDiv</div>')[0]);
controller.updateView(scope);
@@ -174,8 +174,8 @@ BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () {
BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () {
var view = $('<div />');
- var controller = new nglr.BindUpdater(view[0], "{{obj}}");
- var scope = new nglr.Scope();
+ var controller = new BindUpdater(view[0], "{{obj}}");
+ var scope = new Scope();
scope.set("obj", new angular.filter.Meta({text:function(){return "abc";}}));
controller.updateView(scope);
@@ -187,13 +187,13 @@ BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () {
scope.set("obj", {text:"123"});
controller.updateView(scope);
- assertEquals("123", nglr.fromJson(view.text()).text);
+ assertEquals("123", fromJson(view.text()).text);
};
BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () {
var view = $('<div />');
- var controller = new nglr.BindUpdater(view[0], "{{obj}}");
- var scope = new nglr.Scope();
+ var controller = new BindUpdater(view[0], "{{obj}}");
+ var scope = new Scope();
scope.set("obj", new angular.filter.Meta({html:function(){return "a<div>b</div>c";}}));
controller.updateView(scope);
@@ -205,13 +205,13 @@ BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () {
scope.set("obj", {html:"123"});
controller.updateView(scope);
- assertEquals("123", nglr.fromJson(view.text()).html);
+ assertEquals("123", fromJson(view.text()).html);
};
BindUpdaterTest.prototype.testUdateBoolean = function() {
var view = $('<div />');
- var controller = new nglr.BindUpdater(view[0], "{{true}}, {{false}}");
- controller.updateView(new nglr.Scope());
+ var controller = new BindUpdater(view[0], "{{true}}, {{false}}");
+ controller.updateView(new Scope());
assertEquals('true, false', view.text());
};
@@ -219,26 +219,25 @@ BindAttrUpdaterTest = TestCase("BindAttrUpdaterTest");
BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = function () {
var view = $('<img />');
- var controller = new nglr.BindAttrUpdater(view[0], {src: '{{imageUrl}}'});
+ var controller = new BindAttrUpdater(view[0], {src: '{{imageUrl}}'});
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('imageUrl', undefined);
- scope.set('config.server', 'http://server');
+ scope.set('$config.blankImage', 'http://server/blank.gif');
controller.updateView(scope);
- assertEquals("http://server/images/blank.gif", view.attr('src'));
+ assertEquals("http://server/blank.gif", view.attr('src'));
};
-RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest");
RepeaterUpdaterTest.prototype.testShouldNotDieWhenRepeatExpressionIsNull = function() {
- var rep = new nglr.RepeaterUpdater(null, "$item in items", null, null);
- var scope = new nglr.Scope();
+ var rep = new RepeaterUpdater(null, "$item in items", null, null);
+ var scope = new Scope();
scope.set('items', undefined);
rep.updateView(scope);
};
RepeaterUpdaterTest.prototype.testShouldIterateOverKeys = function() {
- var rep = new nglr.RepeaterUpdater(null, "($k,_v) in items", null, null);
+ var rep = new RepeaterUpdater(null, "($k,_v) in items", null, null);
assertEquals("items", rep.iteratorExp);
assertEquals("_v", rep.valueExp);
assertEquals("$k", rep.keyExp);
@@ -247,14 +246,14 @@ RepeaterUpdaterTest.prototype.testShouldIterateOverKeys = function() {
EvalUpdaterTest = TestCase("EvalUpdaterTest");
EvalUpdaterTest.prototype.testEvalThrowsException = function(){
var view = $('<div/>');
- var eval = new nglr.EvalUpdater(view[0], 'undefined()');
+ var eval = new EvalUpdater(view[0], 'undefined()');
- eval.updateView(new nglr.Scope());
+ eval.updateView(new Scope());
assertTrue(!!view.attr('ng-error'));
assertTrue(view.hasClass('ng-exception'));
eval.exp = "1";
- eval.updateView(new nglr.Scope());
+ eval.updateView(new Scope());
assertFalse(!!view.attr('ng-error'));
assertFalse(view.hasClass('ng-exception'));
};
@@ -262,8 +261,8 @@ EvalUpdaterTest.prototype.testEvalThrowsException = function(){
RadioControllerTest = TestCase("RadioController");
RadioControllerTest.prototype.testItShouldTreatTrueStringAsBoolean = function () {
var view = $('<input type="radio" name="select" value="true"/>');
- var radio = new nglr.RadioController(view[0], 'select');
- var scope = new nglr.Scope({select:true});
+ var radio = new RadioController(view[0], 'select');
+ var scope = new Scope({select:true});
radio.updateView(scope);
assertTrue(view[0].checked);
};