feat(module): new module loader

This commit is contained in:
Misko Hevery
2012-01-06 18:10:47 -08:00
parent afd25446d2
commit 5143e7bf06
211 changed files with 1072 additions and 1263 deletions

View File

@@ -116,7 +116,7 @@ describe('angular.scenario.Application', function() {
var called, polled;
var handlers = [];
var testWindow = {
document: jqLite('<div class="test-foo"></div>'),
document: jqLite('<div class="test-foo" ng-app></div>')[0],
angular: {
element: jqLite,
service: {}
@@ -125,7 +125,7 @@ describe('angular.scenario.Application', function() {
$browser.notifyWhenNoOutstandingRequests = function(fn) {
handlers.push(fn);
};
testWindow.document.data('$injector', $injector);
jqLite(testWindow.document).data('$injector', $injector);
app.getWindow_ = function() {
return testWindow;
};

View File

@@ -46,8 +46,8 @@ describe('angular.scenario.Runner', function() {
runner.createSpecRunner_ = function(scope) {
return scope.$new(MockSpecRunner);
};
runner.on('SpecError', angular.module.ngMock.rethrow);
runner.on('StepError', angular.module.ngMock.rethrow);
runner.on('SpecError', angular.mock.rethrow);
runner.on('StepError', angular.mock.rethrow);
});
afterEach(function() {

View File

@@ -7,10 +7,10 @@ describe("angular.scenario.dsl", function() {
beforeEach(inject(function($injector) {
eventLog = [];
$window = {
document: jqLite('<div class="document"></div>'),
document: window.document.body,
angular: new angular.scenario.testing.MockAngular()
};
$window.document.data('$injector', $injector);
jqLite($window.document).data('$injector', $injector).attr('ng-app', '').addClass('html');
$root = $injector.get('$rootScope');
$root.emit = function(eventName) {
eventLog.push(eventName);
@@ -35,7 +35,7 @@ describe("angular.scenario.dsl", function() {
return fn.call($root).apply($root, arguments);
};
});
$root.application = new angular.scenario.Application($window.document);
$root.application = new angular.scenario.Application(jqLite($window.document));
$root.application.getWindow_ = function() {
return $window;
};
@@ -46,6 +46,7 @@ describe("angular.scenario.dsl", function() {
// Just use the real one since it delegates to this.addFuture
$root.addFutureAction = angular.scenario.
SpecRunner.prototype.addFutureAction;
jqLite($window.document).html('');
}));
afterEach(function(){
@@ -202,27 +203,10 @@ describe("angular.scenario.dsl", function() {
describe('Element Finding', function() {
var doc;
//TODO(esprehn): Work around a bug in jQuery where attribute selectors
// only work if they are executed on a real document, not an element.
//
// ex. jQuery('#foo').find('[name="bar"]') // fails
// ex. jQuery('#foo [name="bar"]') // works, wtf?
//
beforeEach(inject(function($injector) {
doc = _jQuery('<div id="angular-scenario-binding"></div>');
_jQuery(document.body).html('').append(doc);
dealoc($window.document); // we are about to override it
$window.document = window.document;
jqLite($window.document).data('$injector', $injector);
doc = _jQuery($window.document).append('<div class="body"></div>').find('.body');
}));
afterEach(function() {
_jQuery(document.body).
find('#angular-scenario-binding').
remove();
});
describe('Select', function() {
it('should select single option', function() {
doc.append(
@@ -232,7 +216,7 @@ describe("angular.scenario.dsl", function() {
'</select>'
);
$root.dsl.select('test').option('A');
expect(_jQuery('[ng\\:model="test"]').val()).toEqual('A');
expect(doc.find('[ng\\:model="test"]').val()).toEqual('A');
});
it('should select option by name', function() {
@@ -243,7 +227,7 @@ describe("angular.scenario.dsl", function() {
'</select>'
);
$root.dsl.select('test').option('one');
expect(_jQuery('[ng\\:model="test"]').val()).toEqual('A');
expect(doc.find('[ng\\:model="test"]').val()).toEqual('A');
});
it('should select multiple options', function() {
@@ -255,7 +239,7 @@ describe("angular.scenario.dsl", function() {
'</select>'
);
$root.dsl.select('test').options('A', 'B');
expect(_jQuery('[ng\\:model="test"]').val()).toEqual(['A','B']);
expect(doc.find('[ng\\:model="test"]').val()).toEqual(['A','B']);
});
it('should fail to select multiple options on non-multiple select', function() {
@@ -318,7 +302,7 @@ describe("angular.scenario.dsl", function() {
it('should set attribute', function() {
doc.append('<div id="test" class="foo"></div>');
$root.dsl.element('#test').attr('class', 'bam');
expect(doc.find('div').attr('class')).toEqual('bam');
expect(doc.find('#test').attr('class')).toEqual('bam');
});
it('should get property', function() {
@@ -330,7 +314,7 @@ describe("angular.scenario.dsl", function() {
it('should set property', function() {
doc.append('<div id="test" class="foo"></div>');
$root.dsl.element('#test').prop('className', 'bam');
expect(doc.find('div').prop('className')).toEqual('bam');
expect(doc.find('#test').prop('className')).toEqual('bam');
});
it('should get css', function() {

View File

@@ -1,8 +1,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:ng="http://angularjs.org">
<head>
<head ng:app>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script type="text/javascript" src="../../../src/angular-bootstrap.js" ng:autobind></script>
<script type="text/javascript" src="../../../src/angular-bootstrap.js"></script>
</head>
<body ng:init="$window.$scope = this">
<table>