mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-03-30 17:03:39 +08:00
tests failing jstd to show cory
This commit is contained in:
98
test/moveToAngularCom/FileControllerTest.js
Normal file
98
test/moveToAngularCom/FileControllerTest.js
Normal file
@@ -0,0 +1,98 @@
|
||||
FileControllerTest = TestCase('FileControllerTest');
|
||||
|
||||
FileControllerTest.prototype.XtestOnSelectUpdateView = function(){
|
||||
var view = jQuery('<span><a/><span/></span>');
|
||||
var swf = {};
|
||||
var controller = new FileController(view, null, swf);
|
||||
swf.uploadFile = function(path){};
|
||||
controller.select('A', 9, '9 bytes');
|
||||
assertEquals(view.find('a').text(), "A");
|
||||
assertEquals(view.find('span').text(), "9 bytes");
|
||||
};
|
||||
|
||||
FileControllerTest.prototype.XtestUpdateModelView = function(){
|
||||
var view = FileController.template('');
|
||||
var input = $('<input name="value.input">');
|
||||
var controller;
|
||||
var scope = new Scope({value:{}, $binder:{updateView:function(){
|
||||
controller.updateView(scope);
|
||||
}}});
|
||||
view.data('scope', scope);
|
||||
controller = new FileController(view, 'value.input', null, "http://server_base");
|
||||
var value = '{"text":"A", "size":123, "id":"890"}';
|
||||
controller.uploadCompleteData(value);
|
||||
controller.updateView(scope);
|
||||
assertEquals(scope.get('value.input.text'), 'A');
|
||||
assertEquals(scope.get('value.input.size'), 123);
|
||||
assertEquals(scope.get('value.input.id'), '890');
|
||||
assertEquals(scope.get('value.input.url'), 'http://server_base/_attachments/890/A');
|
||||
assertEquals(view.find('a').text(), "A");
|
||||
assertEquals(view.find('a').attr('href'), "http://server_base/_attachments/890/A");
|
||||
assertEquals(view.find('span').text(), "123 bytes");
|
||||
};
|
||||
|
||||
FileControllerTest.prototype.XtestFileUpload = function(){
|
||||
expectAsserts(1);
|
||||
var swf = {};
|
||||
var controller = new FileController(null, null, swf, "http://server_base");
|
||||
swf.uploadFile = function(path){
|
||||
assertEquals("http://server_base/_attachments", path);
|
||||
};
|
||||
controller.name = "Name";
|
||||
controller.upload();
|
||||
};
|
||||
|
||||
FileControllerTest.prototype.XtestFileUploadNoFileIsNoop = function(){
|
||||
expectAsserts(0);
|
||||
var swf = {uploadFile:function(path){
|
||||
fail();
|
||||
}};
|
||||
var controller = new FileController(null, swf);
|
||||
controller.upload("basePath", null);
|
||||
};
|
||||
|
||||
FileControllerTest.prototype.XtestRemoveAttachment = function(){
|
||||
var doc = FileController.template();
|
||||
var input = $('<input name="file">');
|
||||
var scope = new Scope();
|
||||
input.data('scope', scope);
|
||||
var controller = new FileController(doc, 'file', null, null);
|
||||
controller.updateView(scope);
|
||||
assertEquals(false, doc.find('input').attr('checked'));
|
||||
|
||||
scope.set('file', {url:'url', size:123});
|
||||
controller.updateView(scope);
|
||||
assertEquals(true, doc.find('input').attr('checked'));
|
||||
|
||||
doc.find('input').attr('checked', false);
|
||||
controller.updateModel(scope);
|
||||
assertNull(scope.get('file'));
|
||||
|
||||
doc.find('input').attr('checked', true);
|
||||
controller.updateModel(scope);
|
||||
assertEquals('url', scope.get('file.url'));
|
||||
assertEquals(123, scope.get('file.size'));
|
||||
};
|
||||
|
||||
FileControllerTest.prototype.XtestShouldEmptyOutOnUndefined = function () {
|
||||
var view = FileController.template('hello');
|
||||
var controller = new FileController(view, 'abc', null, null);
|
||||
|
||||
var scope = new Scope();
|
||||
scope.set('abc', {text: 'myname', url: 'myurl', size: 1234});
|
||||
|
||||
controller.updateView(scope);
|
||||
assertEquals("myurl", view.find('a').attr('href'));
|
||||
assertEquals("myname", view.find('a').text());
|
||||
assertEquals(true, view.find('input').is(':checked'));
|
||||
assertEquals("1.2 KB", view.find('span').text());
|
||||
|
||||
scope.set('abc', undefined);
|
||||
controller.updateView(scope);
|
||||
assertEquals("myurl", view.find('a').attr('href'));
|
||||
assertEquals("myname", view.find('a').text());
|
||||
assertEquals(false, view.find('input').is(':checked'));
|
||||
assertEquals("1.2 KB", view.find('span').text());
|
||||
};
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
62
test/moveToAngularCom/miscTest.js
Normal file
62
test/moveToAngularCom/miscTest.js
Normal file
@@ -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));
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user