aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2010-04-08 13:43:40 -0700
committerMisko Hevery2010-04-08 13:43:40 -0700
commitc4ef1f2fdd73bdaeda879e596d3d96e4e68cb6fd (patch)
tree3fc1943a4599a764aef9a41d995246bb0e48f463 /test
parente0ad7dfcd47196d0aa9271e84b2c4ac26cfda3f4 (diff)
downloadangular.js-c4ef1f2fdd73bdaeda879e596d3d96e4e68cb6fd.tar.bz2
tests failing jstd to show cory
Diffstat (limited to 'test')
-rw-r--r--test/BinderTest.js155
-rw-r--r--test/ConsoleTest.js2
-rw-r--r--test/FiltersTest.js45
-rw-r--r--test/ParserTest.js40
-rw-r--r--test/ScenarioSpec.js37
-rw-r--r--test/ValidatorsTest.js26
-rw-r--r--test/angular-mocks.js6
-rw-r--r--test/directivesSpec.js10
-rw-r--r--test/moveToAngularCom/FileControllerTest.js (renamed from test/FileControllerTest.js)0
-rw-r--r--test/moveToAngularCom/MiscTest.js4
-rw-r--r--test/moveToAngularCom/miscTest.js62
-rw-r--r--test/servicesSpec.js4
-rw-r--r--test/testabilityPatch.js7
13 files changed, 137 insertions, 261 deletions
diff --git a/test/BinderTest.js b/test/BinderTest.js
index 270fd1c7..e72afa9f 100644
--- a/test/BinderTest.js
+++ b/test/BinderTest.js
@@ -174,34 +174,6 @@ BinderTest.prototype.testButtonElementActionExecutesInScope = function(){
assertTrue(savedCalled);
};
-BinderTest.prototype.XtestParseEmptyAnchor = function(){
- var binder = this.compile("<div/>").binder;
- var location = binder.location;
- var anchor = binder.anchor;
- location.url = "a#x=1";
- binder.parseAnchor();
- assertEquals(1, binder.anchor.x);
- location.url = "a#";
- binder.parseAnchor();
- assertTrue("old values did not get removed", !binder.anchor.x);
- assertTrue("anchor gor replaced", anchor === binder.anchor);
- assertEquals('undefined', typeof (anchor[""]));
-};
-
-BinderTest.prototype.XtestParseAnchor = function(){
- var binder = this.compile("<div/>").binder;
- var location = binder.location;
- location.url = "a#x=1";
- binder.parseAnchor();
- assertEquals(binder.anchor.x, "1");
- location.url = "a#a=b&c=%20&d";
- binder.parseAnchor();
- assertEquals(binder.anchor.a, 'b');
- assertEquals(binder.anchor.c, ' ');
- assertTrue(binder.anchor.d !== null);
- assertTrue(!binder.anchor.x);
-};
-
BinderTest.prototype.testRepeaterUpdateBindings = function(){
var a = this.compile('<ul><LI ng-repeat="item in model.items" ng-bind="item.a"/></ul>');
var form = a.node;
@@ -355,18 +327,6 @@ BinderTest.prototype.testNestedRepeater = function() {
'</div></div>', sortedHtml(a.node));
};
-BinderTest.prototype.XtestRadioButtonGetsPrefixed = function () {
- var a = this.compile('<div><input ng-repeat="m in model" type="radio" name="m.a" value="on"/></div>');
- a.scope.$set('model', ['a1', 'a2']);
- a.scope.$eval();
-
- assertEquals('</div>' +
- '<#comment></#comment>'+
- '<input name="0:m.a" ng-repeat-index="0" type="radio" value="on"></input>'+
- '<input name="1:m.a" ng-repeat-index="1" type="radio" value="on"></input></div>',
- sortedHtml(a.node));
-};
-
BinderTest.prototype.testHideBindingExpression = function() {
var a = this.compile('<div ng-hide="hidden == 3"/>');
@@ -525,31 +485,6 @@ BinderTest.prototype.testShouldTemplateBindPreElements = function () {
assertEquals('<pre ng-bind-template="Hello {{name}}!">Hello World!</pre>', sortedHtml(c.node));
};
-BinderTest.prototype.XtestDissableAutoSubmit = function() {
- var c = this.compile('<input type="submit" value="S"/>', null, {autoSubmit:true});
- assertEquals(
- '<input ng-action="$save()" ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}" type="submit" value="S"></input>',
- sortedHtml(c.node));
-
- c = this.compile('<input type="submit" value="S"/>', null, {autoSubmit:false});
- assertEquals(
- '<input type="submit" value="S"></input>',
- sortedHtml(c.node));
-};
-
-BinderTest.prototype.XtestSettingAnchorToNullOrUndefinedRemovesTheAnchorFromURL = function() {
- var c = this.compile('');
- c.binder.location.set("http://server/#a=1&b=2");
- c.binder.parseAnchor();
- assertEquals('1', c.binder.anchor.a);
- assertEquals('2', c.binder.anchor.b);
-
- c.binder.anchor.a = null;
- c.binder.anchor.b = null;
- c.binder.updateAnchor();
- assertEquals('http://server/#', c.binder.location.get());
-};
-
BinderTest.prototype.testFillInOptionValueWhenMissing = function() {
var c = this.compile(
'<select><option selected="true">{{a}}</option><option value="">{{b}}</option><option>C</option></select>');
@@ -570,9 +505,11 @@ BinderTest.prototype.testFillInOptionValueWhenMissing = function() {
expect(optionC.text()).toEqual('C');
};
-BinderTest.prototype.XtestValidateForm = function() {
- var c = this.compile('<input name="name" ng-required>' +
- '<div ng-repeat="item in items"><input name="item.name" ng-required/></div>');
+BinderTest.prototype.testValidateForm = function() {
+ var doc = jqLite(document.body);
+ doc.append('<div><input name="name" ng-required>' +
+ '<div ng-repeat="item in items"><input name="item.name" ng-required/></div></div>');
+ var c = this.compile(doc);
var items = [{}, {}];
c.scope.$set("items", items);
c.scope.$eval();
@@ -599,8 +536,9 @@ BinderTest.prototype.XtestValidateForm = function() {
assertEquals(0, c.scope.$get("$invalidWidgets.length"));
};
-BinderTest.prototype.XtestValidateOnlyVisibleItems = function(){
- var c = this.compile('<input name="name" ng-required><input ng-show="show" name="name" ng-required>');
+BinderTest.prototype.testValidateOnlyVisibleItems = function(){
+ var c = this.compile('<div><input name="name" ng-required><input ng-show="show" name="name" ng-required></div>');
+ jqLite(document.body).append(c.node);
c.scope.$set("show", true);
c.scope.$eval();
assertEquals(2, c.scope.$get("$invalidWidgets.length"));
@@ -629,62 +567,6 @@ BinderTest.prototype.testDeleteAttributeIfEvaluatesFalse = function() {
assertChild(5, false);
};
-BinderTest.prototype.XtestItShouldCallListenersWhenAnchorChanges = function() {
- var log = "";
- var c = this.compile('<div ng-watch="$anchor.counter:count = count+1">');
- c.scope.$set("count", 0);
- c.scope.$watch("$anchor.counter", function(newValue, oldValue){
- log += oldValue + "->" + newValue + ";";
- });
- assertEquals(0, c.scope.$get("count"));
- c.binder.location.url = "#counter=1";
- c.binder.onUrlChange();
- assertEquals(1, c.scope.$get("count"));
-
- c.binder.location.url = "#counter=1";
- c.binder.onUrlChange();
- assertEquals(1, c.scope.$get("count"));
-
- c.binder.location.url = "#counter=2";
- c.binder.onUrlChange();
- assertEquals(2, c.scope.$get("count"));
-
- c.binder.location.url = "#counter=2";
- c.binder.onUrlChange();
- assertEquals(2, c.scope.$get("count"));
-
- c.binder.location.url = "#";
- c.binder.onUrlChange();
- assertEquals("undefined->1;1->2;2->undefined;", log);
- assertEquals(3, c.scope.$get("count"));
-};
-
-BinderTest.prototype.XtestParseQueryString = function(){
- var binder = new Binder();
- assertJsonEquals({"a":"1"}, binder.parseQueryString("a=1"));
- assertJsonEquals({"a":"1", "b":"two"}, binder.parseQueryString("a=1&b=two"));
- assertJsonEquals({}, binder.parseQueryString(""));
-
- assertJsonEquals({"a":"1", "b":""}, binder.parseQueryString("a=1&b="));
- assertJsonEquals({"a":"1", "b":""}, binder.parseQueryString("a=1&b"));
- assertJsonEquals({"a":"1", "b":" 2 "}, binder.parseQueryString("a=1&b=%202%20"));
- assertJsonEquals({"a a":"1", "b":"2"}, binder.parseQueryString("a%20a=1&b=2"));
-
-};
-
-BinderTest.prototype.XtestSetBinderAnchorTriggersListeners = function(){
- expectAsserts(2);
- var doc = this.compile("<div/>");
-
- doc.scope.$watch("$anchor.name", function(newVal, oldVal) {
- assertEquals("new", newVal);
- assertEquals(undefined, oldVal);
- });
-
- doc.$anchor.name = "new";
- doc.binder.onUrlChange("http://base#name=new");
-};
-
BinderTest.prototype.testItShouldDisplayErrorWhenActionIsSyntacticlyIncorect = function(){
var c = this.compile('<div>' +
'<input type="button" ng-click="greeting=\'ABC\'"/>' +
@@ -768,9 +650,9 @@ BinderTest.prototype.testItBindHiddenInputFields = function(){
assertEquals("abc", x.scope.$get("myName"));
};
-BinderTest.prototype.xtestItShouldRenderMultiRootHtmlInBinding = function() {
+BinderTest.prototype.XtestItShouldRenderMultiRootHtmlInBinding = function() {
var x = this.compile('<div>before {{a|html}}after</div>');
- x.scope.$set("a", "a<b>c</b>d");
+ x.scope.a = "a<b>c</b>d";
x.scope.$eval();
assertEquals(
'<div>before <span ng-bind="a|html">a<b>c</b>d</span>after</div>',
@@ -790,20 +672,3 @@ BinderTest.prototype.testItShouldUseFormaterForText = function() {
assertEquals('1, 2, 3', input[0].value);
};
-BinderTest.prototype.XtestWriteAnchor = function(){
- var binder = this.compile("<div/>").binder;
- binder.location.set('a');
- binder.anchor.a = 'b';
- binder.anchor.c = ' ';
- binder.anchor.d = true;
- binder.updateAnchor();
- assertEquals(binder.location.get(), "a#a=b&c=%20&d");
-};
-
-BinderTest.prototype.XtestWriteAnchorAsPartOfTheUpdateView = function(){
- var binder = this.compile("<div/>").binder;
- binder.location.set('a');
- binder.anchor.a = 'b';
- binder.updateView();
- assertEquals(binder.location.get(), "a#a=b");
-};
diff --git a/test/ConsoleTest.js b/test/ConsoleTest.js
index 9adb50f8..3e09267b 100644
--- a/test/ConsoleTest.js
+++ b/test/ConsoleTest.js
@@ -7,6 +7,6 @@ ConsoleTest.prototype.XtestConsoleWrite = function(){
assertEquals(jqLite(consoleNode).text(), 'Hello world');
assertEquals(jqLite(consoleNode.childNodes[0])[0].className, 'error');
consoleLog("error",["Bye"]);
- assertEquals($(consoleNode).text(), 'Hello worldBye');
+ assertEquals(jqLite(consoleNode).text(), 'Hello worldBye');
consoleNode = null;
};
diff --git a/test/FiltersTest.js b/test/FiltersTest.js
index fd5c9976..504dad02 100644
--- a/test/FiltersTest.js
+++ b/test/FiltersTest.js
@@ -1,8 +1,8 @@
FiltersTest = TestCase('FiltersTest');
-FiltersTest.prototype.XtestCurrency = function(){
- var html = $('<span/>');
- var context = {$element:html[0]};
+FiltersTest.prototype.testCurrency = function(){
+ var html = jqLite('<span/>');
+ var context = {$element:html};
var currency = bind(context, angular.filter.currency);
assertEquals(currency(0), '$0.00');
@@ -24,8 +24,8 @@ FiltersTest.prototype.testFilterThisIsContext = function(){
delete angular.filter['testFn'];
};
-FiltersTest.prototype.XtestNumberFormat = function(){
- var context = {jqElement:$('<span/>')};
+FiltersTest.prototype.testNumberFormat = function(){
+ var context = {jqElement:jqLite('<span/>')};
var number = bind(context, angular.filter.number);
assertEquals('0', number(0, 0));
@@ -37,11 +37,11 @@ FiltersTest.prototype.XtestNumberFormat = function(){
assertEquals("", number(1/0));
};
-FiltersTest.prototype.XtestJson = function () {
- assertEquals(toJson({a:"b"}, true), angular.filter.json({a:"b"}));
+FiltersTest.prototype.testJson = function () {
+ assertEquals(toJson({a:"b"}, true), angular.filter.json.call({$element:jqLite('<div></div>')}, {a:"b"}));
};
-FiltersTest.prototype.XtestPackageTracking = function () {
+FiltersTest.prototype.testPackageTracking = function () {
var assert = function(title, trackingNo) {
var val = angular.filter.trackPackage(trackingNo, title);
assertNotNull("Did Not Match: " + trackingNo, val);
@@ -69,7 +69,7 @@ FiltersTest.prototype.XtestPackageTracking = function () {
assert('USPS', '9102801438635051633253');
};
-FiltersTest.prototype.XtestLink = function() {
+FiltersTest.prototype.testLink = function() {
var assert = function(text, url, obj){
var val = angular.filter.link(obj);
assertEquals(angular.filter.Meta.TAG, val.TAG);
@@ -80,14 +80,7 @@ FiltersTest.prototype.XtestLink = function() {
assert("a@b.com", "mailto:a@b.com", "a@b.com");
};
-FiltersTest.prototype.XtestBytes = function(){
- var controller = new FileController();
- assertEquals(angular.filter.bytes(123), '123 bytes');
- assertEquals(angular.filter.bytes(1234), '1.2 KB');
- assertEquals(angular.filter.bytes(1234567), '1.1 MB');
-};
-
-FiltersTest.prototype.XtestImage = function(){
+FiltersTest.prototype.testImage = function(){
assertEquals(null, angular.filter.image());
assertEquals(null, angular.filter.image({}));
assertEquals(null, angular.filter.image(""));
@@ -100,7 +93,7 @@ FiltersTest.prototype.XtestImage = function(){
angular.filter.image({url:"abc"}, 10, 20).html);
};
-FiltersTest.prototype.XtestQRcode = function() {
+FiltersTest.prototype.testQRcode = function() {
assertEquals(
'<img width="200" height="200" src="http://chart.apis.google.com/chart?chl=Hello%20world&chs=200x200&cht=qr"/>',
angular.filter.qrcode('Hello world').html);
@@ -109,17 +102,17 @@ FiltersTest.prototype.XtestQRcode = function() {
angular.filter.qrcode('http://server?a&b=c', 100).html);
};
-FiltersTest.prototype.XtestLowercase = function() {
+FiltersTest.prototype.testLowercase = function() {
assertEquals('abc', angular.filter.lowercase('AbC'));
assertEquals(null, angular.filter.lowercase(null));
};
-FiltersTest.prototype.XtestUppercase = function() {
+FiltersTest.prototype.testUppercase = function() {
assertEquals('ABC', angular.filter.uppercase('AbC'));
assertEquals(null, angular.filter.uppercase(null));
};
-FiltersTest.prototype.XtestLineCount = function() {
+FiltersTest.prototype.testLineCount = function() {
assertEquals(1, angular.filter.linecount(null));
assertEquals(1, angular.filter.linecount(''));
assertEquals(1, angular.filter.linecount('a'));
@@ -127,30 +120,30 @@ FiltersTest.prototype.XtestLineCount = function() {
assertEquals(3, angular.filter.linecount('a\nb\nc'));
};
-FiltersTest.prototype.XtestIf = function() {
+FiltersTest.prototype.testIf = function() {
assertEquals('A', angular.filter['if']('A', true));
assertEquals(undefined, angular.filter['if']('A', false));
};
-FiltersTest.prototype.XtestUnless = function() {
+FiltersTest.prototype.testUnless = function() {
assertEquals('A', angular.filter.unless('A', false));
assertEquals(undefined, angular.filter.unless('A', true));
};
-FiltersTest.prototype.XtestGoogleChartApiEncode = function() {
+FiltersTest.prototype.testGoogleChartApiEncode = function() {
assertEquals(
'<img width="200" height="200" src="http://chart.apis.google.com/chart?chl=Hello world&chs=200x200&cht=qr"/>',
angular.filter.googleChartApi.encode({cht:"qr", chl:"Hello world"}).html);
};
-FiltersTest.prototype.XtestHtml = function() {
+FiltersTest.prototype.testHtml = function() {
assertEquals(
"a<b>c</b>d",
angular.filter.html("a<b>c</b>d").html);
assertTrue(angular.filter.html("a<b>c</b>d") instanceof angular.filter.Meta);
};
-FiltersTest.prototype.XtestLinky = function() {
+FiltersTest.prototype.testLinky = function() {
var linky = angular.filter.linky;
assertEquals(
'<a href="http://ab">http://ab</a> ' +
diff --git a/test/ParserTest.js b/test/ParserTest.js
index 6170dd4a..7ba65f18 100644
--- a/test/ParserTest.js
+++ b/test/ParserTest.js
@@ -404,36 +404,6 @@ ParserTest.prototype.testMissingThrowsError = function() {
}
};
-ParserTest.prototype.XtestItShouldParseOnChangeIntoHashSet = function () {
- var scope = createScope({count:0});
- scope.watch("$anchor.a:count=count+1;$anchor.a:count=count+20;b:count=count+300");
-
- scope.watchListeners["$anchor.a"].listeners[0]();
- assertEquals(1, scope.$get("count"));
- scope.watchListeners["$anchor.a"].listeners[1]();
- assertEquals(21, scope.$get("count"));
- scope.watchListeners["b"].listeners[0]({scope:scope});
- assertEquals(321, scope.$get("count"));
-};
-ParserTest.prototype.XtestItShouldParseOnChangeBlockIntoHashSet = function () {
- var scope = createScope({count:0});
- var listeners = {a:[], b:[]};
- scope.watch("a:{count=count+1;count=count+20;};b:count=count+300",
- function(n, fn){listeners[n].push(fn);});
-
- assertEquals(1, scope.watchListeners.a.listeners.length);
- assertEquals(1, scope.watchListeners.b.listeners.length);
- scope.watchListeners["a"].listeners[0]();
- assertEquals(21, scope.$get("count"));
- scope.watchListeners["b"].listeners[0]();
- assertEquals(321, scope.$get("count"));
-};
-
-ParserTest.prototype.XtestItShouldParseEmptyOnChangeAsNoop = function () {
- var scope = createScope();
- scope.watch("", function(){fail();});
-};
-
ParserTest.prototype.testItShouldCreateClosureFunctionWithNoArguments = function () {
var scope = createScope();
var fn = scope.$eval("{:value}");
@@ -462,16 +432,6 @@ ParserTest.prototype.testItShouldHaveDefaultArugument = function(){
assertEquals(4, fn(2));
};
-ParserTest.prototype.XtestReturnFunctionsAreNotBound = function(){
- var scope = createScope();
- scope.entity("Group", new DataStore());
- var Group = scope.$get("Group");
- assertEquals("eval Group", "function", typeof scope.$eval("Group"));
- assertEquals("direct Group", "function", typeof Group);
- assertEquals("eval Group.all", "function", typeof scope.$eval("Group.query"));
- assertEquals("direct Group.all", "function", typeof Group.query);
-};
-
ParserTest.prototype.testDoubleNegationBug = function (){
var scope = createScope();
assertEquals(true, scope.$eval('true'));
diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js
index ff3a55b5..9afe8e95 100644
--- a/test/ScenarioSpec.js
+++ b/test/ScenarioSpec.js
@@ -19,46 +19,33 @@ describe("ScenarioSpec: Compilation", function(){
});
describe("ScenarioSpec: Scope", function(){
- xit("should have set, get, eval, $init, updateView methods", function(){
+ it("should have set, get, eval, $init, updateView methods", function(){
var scope = compile('<div>{{a}}</div>').$init();
scope.$eval("$invalidWidgets.push({})");
expect(scope.$set("a", 2)).toEqual(2);
expect(scope.$get("a")).toEqual(2);
expect(scope.$eval("a=3")).toEqual(3);
scope.$eval();
- expect(scope.$eval("$invalidWidgets")).toEqual([]);
expect(jqLite(scope.$element).text()).toEqual('3');
});
- xit("should have $ objects", function(){
- var scope = compile('<div></div>', {a:"b"});
- expect(scope.$get('$anchor')).toBeDefined();
+ it("should have $ objects", function(){
+ var scope = compile('<div></div>', {$config: {a:"b"}});
+ expect(scope.$get('$location')).toBeDefined();
expect(scope.$get('$eval')).toBeDefined();
expect(scope.$get('$config')).toBeDefined();
expect(scope.$get('$config.a')).toEqual("b");
- expect(scope.$get('$datastore')).toBeDefined();
});
});
-xdescribe("ScenarioSpec: configuration", function(){
+describe("ScenarioSpec: configuration", function(){
it("should take location object", function(){
- var url = "http://server/#book=moby";
- var onUrlChange;
- var location = {
- listen:function(fn){onUrlChange=fn;},
- set:function(u){url = u;},
- get:function(){return url;}
- };
- var scope = compile("<div>{{$anchor}}</div>", {location:location});
- var $anchor = scope.$get('$anchor');
- expect($anchor.book).toBeUndefined();
- expect(onUrlChange).toBeUndefined();
- scope.$init();
- expect($anchor.book).toEqual('moby');
- expect(onUrlChange).toBeDefined();
-
- url = "http://server/#book=none";
- onUrlChange();
- expect($anchor.book).toEqual('none');
+ var url = "http://server/#?book=moby";
+ var scope = compile("<div>{{$location}}</div>");
+ var $location = scope.$get('$location');
+ expect($location.hashSearch.book).toBeUndefined();
+ scope.$browser.setUrl(url);
+ scope.$browser.fireUrlWatchers();
+ expect($location.hashSearch.book).toEqual('moby');
});
});
diff --git a/test/ValidatorsTest.js b/test/ValidatorsTest.js
index 4dfe6892..2b2f6753 100644
--- a/test/ValidatorsTest.js
+++ b/test/ValidatorsTest.js
@@ -1,20 +1,20 @@
ValidatorTest = TestCase('ValidatorTest');
-ValidatorTest.prototype.XtestItShouldHaveThisSet = function() {
- expectAsserts(5);
- var self;
+ValidatorTest.prototype.testItShouldHaveThisSet = function() {
+ var validator = {};
angular.validator.myValidator = function(first, last){
- assertEquals('misko', first);
- assertEquals('hevery', last);
- self = this;
+ validator.first = first;
+ validator.last = last;
+ validator._this = this;
};
- var c = compile('<input name="name" ng-validate="myValidator:\'hevery\'"/>');
- c.scope.$set('name', 'misko');
- c.scope.$set('state', 'abc');
- c.scope.$eval();
- assertEquals('abc', self.state);
- assertEquals('misko', self.name);
- assertEquals('name', self.$element.name);
+ var scope = compile('<input name="name" ng-validate="myValidator:\'hevery\'"/>');
+ scope.name = 'misko';
+ scope.$init();
+ assertEquals('misko', validator.first);
+ assertEquals('hevery', validator.last);
+ assertSame(scope, validator._this);
+ delete angular.validator.myValidator;
+ scope.$element.remove();
};
ValidatorTest.prototype.testRegexp = function() {
diff --git a/test/angular-mocks.js b/test/angular-mocks.js
index e10ad4e2..88552aad 100644
--- a/test/angular-mocks.js
+++ b/test/angular-mocks.js
@@ -45,6 +45,12 @@ MockBrowser.prototype = {
watchUrl: function(fn) {
this.watches.push(fn);
+ },
+
+ fireUrlWatchers: function() {
+ for(var i=0; i<this.watches.length; i++) {
+ this.watches[i](this.url);
+ }
}
};
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index a92e98ee..0af61997 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -141,20 +141,22 @@ describe("directives", function(){
it('should ng-show', function(){
var scope = compile('<div ng-hide="hide"></div>');
+ jqLite(document.body).append(scope.$element);
scope.$eval();
- expect(isVisible(element)).toEqual(true);
+ expect(isVisible(scope.$element)).toEqual(true);
scope.$set('hide', true);
scope.$eval();
- expect(isVisible(element)).toEqual(false);
+ expect(isVisible(scope.$element)).toEqual(false);
});
it('should ng-hide', function(){
var scope = compile('<div ng-show="show"></div>');
+ jqLite(document.body).append(scope.$element);
scope.$eval();
- expect(isVisible(element)).toEqual(false);
+ expect(isVisible(scope.$element)).toEqual(false);
scope.$set('show', true);
scope.$eval();
- expect(isVisible(element)).toEqual(true);
+ expect(isVisible(scope.$element)).toEqual(true);
});
it('should ng-controller', function(){
diff --git a/test/FileControllerTest.js b/test/moveToAngularCom/FileControllerTest.js
index 75c924e6..75c924e6 100644
--- a/test/FileControllerTest.js
+++ b/test/moveToAngularCom/FileControllerTest.js
diff --git a/test/moveToAngularCom/MiscTest.js b/test/moveToAngularCom/MiscTest.js
index db6e8563..aa0e1186 100644
--- a/test/moveToAngularCom/MiscTest.js
+++ b/test/moveToAngularCom/MiscTest.js
@@ -7,13 +7,13 @@ BinderTest.prototype.testExpandEntityTagWithName = function(){
assertEquals("friend", c.scope.$get("friend.$$anchor"));
};
-BinderTest.prototype.XtestExpandSubmitButtonToAction = function(){
+BinderTest.prototype.testExpandSubmitButtonToAction = function(){
var html = this.compileToHtml('<input type="submit" value="Save">');
assertTrue(html, html.indexOf('ng-action="$save()"') > 0 );
assertTrue(html, html.indexOf('ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}"') > 0 );
};
-BinderTest.prototype.XtestReplaceFileUploadWithSwf = function(){
+BinderTest.prototype.testReplaceFileUploadWithSwf = function(){
expectAsserts(1);
var form = jQuery("body").append('<div id="testTag"><input type="file"></div>');
form.data('scope', new Scope());
diff --git a/test/moveToAngularCom/miscTest.js b/test/moveToAngularCom/miscTest.js
new file mode 100644
index 00000000..a986f259
--- /dev/null
+++ b/test/moveToAngularCom/miscTest.js
@@ -0,0 +1,62 @@
+ParserTest.prototype.testReturnFunctionsAreNotBound = function(){
+ var scope = createScope();
+ scope.entity("Group", new DataStore());
+ var Group = scope.$get("Group");
+ assertEquals("eval Group", "function", typeof scope.$eval("Group"));
+ assertEquals("direct Group", "function", typeof Group);
+ assertEquals("eval Group.all", "function", typeof scope.$eval("Group.query"));
+ assertEquals("direct Group.all", "function", typeof Group.query);
+};
+
+ParserTest.prototype.XtestItShouldParseEmptyOnChangeAsNoop = function () {
+ var scope = createScope();
+ scope.watch("", function(){fail();});
+};
+
+
+ParserTest.prototype.XtestItShouldParseOnChangeIntoHashSet = function () {
+ var scope = createScope({count:0});
+ scope.watch("$anchor.a:count=count+1;$anchor.a:count=count+20;b:count=count+300");
+
+ scope.watchListeners["$anchor.a"].listeners[0]();
+ assertEquals(1, scope.$get("count"));
+ scope.watchListeners["$anchor.a"].listeners[1]();
+ assertEquals(21, scope.$get("count"));
+ scope.watchListeners["b"].listeners[0]({scope:scope});
+ assertEquals(321, scope.$get("count"));
+};
+ParserTest.prototype.XtestItShouldParseOnChangeBlockIntoHashSet = function () {
+ var scope = createScope({count:0});
+ var listeners = {a:[], b:[]};
+ scope.watch("a:{count=count+1;count=count+20;};b:count=count+300",
+ function(n, fn){listeners[n].push(fn);});
+
+ assertEquals(1, scope.watchListeners.a.listeners.length);
+ assertEquals(1, scope.watchListeners.b.listeners.length);
+ scope.watchListeners["a"].listeners[0]();
+ assertEquals(21, scope.$get("count"));
+ scope.watchListeners["b"].listeners[0]();
+ assertEquals(321, scope.$get("count"));
+};
+
+FiltersTest.prototype.testBytes = function(){
+ var controller = new FileController();
+ assertEquals(angular.filter.bytes(123), '123 bytes');
+ assertEquals(angular.filter.bytes(1234), '1.2 KB');
+ assertEquals(angular.filter.bytes(1234567), '1.1 MB');
+};
+
+BinderTest.prototype.testDissableAutoSubmit = function() {
+ var c = this.compile('<input type="submit" value="S"/>', null, {autoSubmit:true});
+ assertEquals(
+ '<input ng-action="$save()" ng-bind-attr="{"disabled":"{{$invalidWidgets}}"}" type="submit" value="S"></input>',
+ sortedHtml(c.node));
+
+ c = this.compile('<input type="submit" value="S"/>', null, {autoSubmit:false});
+ assertEquals(
+ '<input type="submit" value="S"></input>',
+ sortedHtml(c.node));
+};
+
+
+
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index b7dfe4c8..a3841c2f 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -66,7 +66,9 @@ describe("service $invalidWidgets", function(){
});
it("should count number of invalid widgets", function(){
- var scope = compile('<input name="price" ng-required></input>').$init();
+ var doc = jqLite(window.document.body);
+ doc.append('<input name="price" ng-required></input>');
+ var scope = compile(doc).$init();
expect(scope.$invalidWidgets.length).toEqual(1);
scope.price = 123;
scope.$eval();
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js
index 475784ad..5955e9a6 100644
--- a/test/testabilityPatch.js
+++ b/test/testabilityPatch.js
@@ -74,19 +74,18 @@ function sortedHtml(element) {
return html;
}
-function isVisible(node) {
+function isCssVisible(node) {
var display = node.css('display');
if (display == 'block') display = "";
return display != 'none';
}
function assertHidden(node) {
- var display = node.css('display');
- assertFalse("Node should be hidden but vas visible: " + sortedHtml(node), isVisible(node));
+ assertFalse("Node should be hidden but vas visible: " + sortedHtml(node), isCssVisible(node));
}
function assertVisible(node) {
- assertTrue("Node should be visible but vas hidden: " + sortedHtml(node), isVisible(node));
+ assertTrue("Node should be visible but vas hidden: " + sortedHtml(node), isCssVisible(node));
}
function assertJsonEquals(expected, actual) {