mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-03-29 08:49:06 +08:00
Merge branch 'directives' of github.com:angular/angular.js into directives
This commit is contained in:
@@ -706,13 +706,13 @@ BinderTest.prototype.testItShouldSelectTheCorrectRadioBox = function() {
|
||||
var female = jqLite(c.node[0].childNodes[0]);
|
||||
var male = jqLite(c.node[0].childNodes[1]);
|
||||
|
||||
female.click();
|
||||
trigger(female, 'click');
|
||||
assertEquals("female", c.scope.sex);
|
||||
assertEquals(true, female[0].checked);
|
||||
assertEquals(false, male[0].checked);
|
||||
assertEquals("female", female.val());
|
||||
|
||||
male.click();
|
||||
trigger(male, 'click');
|
||||
assertEquals("male", c.scope.sex);
|
||||
assertEquals(false, female[0].checked);
|
||||
assertEquals(true, male[0].checked);
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('compiler', function(){
|
||||
var scope = compile('<span hello="misko" stop="true"><span hello="adam"/></span>');
|
||||
expect(log).toEqual("hello misko");
|
||||
});
|
||||
|
||||
|
||||
it('should allow creation of templates', function(){
|
||||
directives.duplicate = function(expr, element){
|
||||
element.replaceWith(document.createComment("marker"));
|
||||
@@ -97,7 +97,7 @@ describe('compiler', function(){
|
||||
if (text == 'middle') {
|
||||
expect(textNode.text()).toEqual(text);
|
||||
parentNode.attr('hello', text);
|
||||
textNode.text('replaced');
|
||||
textNode[0].textContent = 'replaced';
|
||||
}
|
||||
});
|
||||
var scope = compile('before<span>middle</span>after');
|
||||
|
||||
@@ -142,19 +142,19 @@ describe("directives", function(){
|
||||
it('should ng-show', function(){
|
||||
var scope = compile('<div ng-hide="hide"></div>');
|
||||
scope.$eval();
|
||||
expect(element.css('display')).toEqual('');
|
||||
expect(isVisible(element)).toEqual(true);
|
||||
scope.$set('hide', true);
|
||||
scope.$eval();
|
||||
expect(element.css('display')).toEqual('none');
|
||||
expect(isVisible(element)).toEqual(false);
|
||||
});
|
||||
|
||||
it('should ng-hide', function(){
|
||||
var scope = compile('<div ng-show="show"></div>');
|
||||
scope.$eval();
|
||||
expect(element.css('display')).toEqual('none');
|
||||
expect(isVisible(element)).toEqual(false);
|
||||
scope.$set('show', true);
|
||||
scope.$eval();
|
||||
expect(element.css('display')).toEqual('');
|
||||
expect(isVisible(element)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should ng-controller', function(){
|
||||
|
||||
@@ -27,6 +27,12 @@ extend(angular, {
|
||||
});
|
||||
|
||||
|
||||
function trigger(element, type) {
|
||||
var evnt = document.createEvent('MouseEvent');
|
||||
evnt.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
(element[0] || element).dispatchEvent(evnt);
|
||||
}
|
||||
|
||||
function sortedHtml(element) {
|
||||
var html = "";
|
||||
(function toString(node) {
|
||||
|
||||
@@ -115,10 +115,10 @@ describe("input widget", function(){
|
||||
it('should type="checkbox"', function(){
|
||||
compile('<input type="checkbox" name="checkbox" checked ng-change="action = true"/>');
|
||||
expect(scope.checkbox).toEqual(true);
|
||||
element.click();
|
||||
trigger(element, 'click');
|
||||
expect(scope.checkbox).toEqual(false);
|
||||
expect(scope.action).toEqual(true);
|
||||
element.click();
|
||||
trigger(element, 'click');
|
||||
expect(scope.checkbox).toEqual(true);
|
||||
});
|
||||
|
||||
@@ -142,7 +142,7 @@ describe("input widget", function(){
|
||||
expect(b.checked).toEqual(true);
|
||||
expect(scope.clicked).not.toBeDefined();
|
||||
|
||||
jqLite(a).click();
|
||||
trigger(a, 'click');
|
||||
expect(scope.chose).toEqual('A');
|
||||
expect(scope.clicked).toEqual(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user