chore: move core modules into core directory
BREAKING CHANGE: This change moves the http module into angular2/, so its import path is now angular2/http instead of http/http. Many other modules have also been moved around inside of angular2, but the public API paths have not changed as of this commit.
This commit is contained in:
5
modules/angular2/test/core/services/rectangle_mock.dart
Normal file
5
modules/angular2/test/core/services/rectangle_mock.dart
Normal file
@ -0,0 +1,5 @@
|
||||
import 'dart:html';
|
||||
|
||||
Rectangle createRectangle(left, top, width, height) {
|
||||
return new Rectangle(left, top, width, height);
|
||||
}
|
3
modules/angular2/test/core/services/rectangle_mock.ts
Normal file
3
modules/angular2/test/core/services/rectangle_mock.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function createRectangle(left, top, width, height) {
|
||||
return {left, top, width, height};
|
||||
}
|
74
modules/angular2/test/core/services/ruler_spec.ts
Normal file
74
modules/angular2/test/core/services/ruler_spec.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
inject,
|
||||
ddescribe,
|
||||
describe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
SpyObject,
|
||||
proxy
|
||||
} from 'angular2/test_lib';
|
||||
|
||||
import {DOM, DomAdapter} from 'angular2/src/dom/dom_adapter';
|
||||
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
||||
|
||||
import {Ruler, Rectangle} from 'angular2/src/services/ruler';
|
||||
import {createRectangle} from './rectangle_mock';
|
||||
import {IMPLEMENTS} from 'angular2/src/facade/lang';
|
||||
|
||||
function assertDimensions(rect: Rectangle, left, right, top, bottom, width, height) {
|
||||
expect(rect.left).toEqual(left);
|
||||
expect(rect.right).toEqual(right);
|
||||
expect(rect.top).toEqual(top);
|
||||
expect(rect.bottom).toEqual(bottom);
|
||||
expect(rect.width).toEqual(width);
|
||||
expect(rect.height).toEqual(height);
|
||||
}
|
||||
|
||||
export function main() {
|
||||
describe('ruler service', () => {
|
||||
|
||||
it('should allow measuring ElementRefs', inject([AsyncTestCompleter], (async) => {
|
||||
var ruler = new Ruler(SpyObject.stub(
|
||||
new SpyDomAdapter(), {'getBoundingClientRect': createRectangle(10, 20, 200, 100)}));
|
||||
|
||||
var elRef = <any>new SpyElementRef();
|
||||
ruler.measure(elRef).then((rect) => {
|
||||
assertDimensions(rect, 10, 210, 20, 120, 200, 100);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
it('should return 0 for all rectangle values while measuring elements in a document fragment',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var ruler = new Ruler(DOM);
|
||||
var elRef = <any>new SpyElementRef();
|
||||
elRef.nativeElement = DOM.createElement('div');
|
||||
ruler.measure(elRef).then((rect) => {
|
||||
// here we are using an element created in a doc fragment so all the measures will come
|
||||
// back as 0
|
||||
assertDimensions(rect, 0, 0, 0, 0, 0, 0);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@proxy
|
||||
@IMPLEMENTS(ElementRef)
|
||||
class SpyElementRef extends SpyObject {
|
||||
nativeElement;
|
||||
constructor() { super(ElementRef); }
|
||||
noSuchMethod(m) { return super.noSuchMethod(m) }
|
||||
}
|
||||
|
||||
@proxy
|
||||
@IMPLEMENTS(DomAdapter)
|
||||
class SpyDomAdapter extends SpyObject {
|
||||
constructor() { super(DomAdapter); }
|
||||
noSuchMethod(m) { return super.noSuchMethod(m) }
|
||||
}
|
@ -0,0 +1 @@
|
||||
<p>hey</p>
|
28
modules/angular2/test/core/services/title_spec.ts
Normal file
28
modules/angular2/test/core/services/title_spec.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import {ddescribe, describe, it, iit, xit, expect, afterEach} from 'angular2/test_lib';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {Title} from 'angular2/src/services/title';
|
||||
|
||||
export function main() {
|
||||
describe('title service', () => {
|
||||
var initialTitle = DOM.getTitle();
|
||||
var titleService = new Title();
|
||||
|
||||
afterEach(() => { DOM.setTitle(initialTitle); });
|
||||
|
||||
it('should allow reading initial title',
|
||||
() => { expect(titleService.getTitle()).toEqual(initialTitle); });
|
||||
|
||||
it('should set a title on the injected document', () => {
|
||||
titleService.setTitle('test title');
|
||||
expect(DOM.getTitle()).toEqual('test title');
|
||||
expect(titleService.getTitle()).toEqual('test title');
|
||||
});
|
||||
|
||||
it('should reset title to empty string if title not provided', () => {
|
||||
titleService.setTitle(null);
|
||||
expect(DOM.getTitle()).toEqual('');
|
||||
});
|
||||
|
||||
});
|
||||
}
|
82
modules/angular2/test/core/services/url_resolver_spec.ts
Normal file
82
modules/angular2/test/core/services/url_resolver_spec.ts
Normal file
@ -0,0 +1,82 @@
|
||||
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/test_lib';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
|
||||
export function main() {
|
||||
describe('UrlResolver', () => {
|
||||
var resolver = new UrlResolver();
|
||||
|
||||
describe('absolute base url', () => {
|
||||
it('should add a relative path to the base url', () => {
|
||||
expect(resolver.resolve('http://www.foo.com', 'bar')).toEqual('http://www.foo.com/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/', 'bar')).toEqual('http://www.foo.com/bar');
|
||||
expect(resolver.resolve('http://www.foo.com', './bar')).toEqual('http://www.foo.com/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/', './bar')).toEqual('http://www.foo.com/bar');
|
||||
});
|
||||
|
||||
it('should replace the base path', () => {
|
||||
expect(resolver.resolve('http://www.foo.com/baz', 'bar')).toEqual('http://www.foo.com/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/baz', './bar'))
|
||||
.toEqual('http://www.foo.com/bar');
|
||||
});
|
||||
|
||||
it('should append to the base path', () => {
|
||||
expect(resolver.resolve('http://www.foo.com/baz/', 'bar'))
|
||||
.toEqual('http://www.foo.com/baz/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/baz/', './bar'))
|
||||
.toEqual('http://www.foo.com/baz/bar');
|
||||
});
|
||||
|
||||
it('should support ".." in the path', () => {
|
||||
expect(resolver.resolve('http://www.foo.com/baz/', '../bar'))
|
||||
.toEqual('http://www.foo.com/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/1/2/3/', '../../bar'))
|
||||
.toEqual('http://www.foo.com/1/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/1/2/3/', '../biz/bar'))
|
||||
.toEqual('http://www.foo.com/1/2/biz/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/1/2/baz', '../../bar'))
|
||||
.toEqual('http://www.foo.com/bar');
|
||||
});
|
||||
|
||||
it('should ignore the base path when the url has a scheme', () => {
|
||||
expect(resolver.resolve('http://www.foo.com', 'http://www.bar.com'))
|
||||
.toEqual('http://www.bar.com');
|
||||
});
|
||||
|
||||
it('should support absolute urls', () => {
|
||||
expect(resolver.resolve('http://www.foo.com', '/bar')).toEqual('http://www.foo.com/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/', '/bar')).toEqual('http://www.foo.com/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/baz', '/bar'))
|
||||
.toEqual('http://www.foo.com/bar');
|
||||
expect(resolver.resolve('http://www.foo.com/baz/', '/bar'))
|
||||
.toEqual('http://www.foo.com/bar');
|
||||
});
|
||||
});
|
||||
|
||||
describe('relative base url', () => {
|
||||
it('should add a relative path to the base url', () => {
|
||||
expect(resolver.resolve('foo/', './bar')).toEqual('foo/bar');
|
||||
expect(resolver.resolve('foo/baz', './bar')).toEqual('foo/bar');
|
||||
expect(resolver.resolve('foo/baz', 'bar')).toEqual('foo/bar');
|
||||
|
||||
});
|
||||
|
||||
it('should support ".." in the path', () => {
|
||||
expect(resolver.resolve('foo/baz', '../bar')).toEqual('bar');
|
||||
expect(resolver.resolve('foo/baz', '../biz/bar')).toEqual('biz/bar');
|
||||
});
|
||||
|
||||
it('should support absolute urls', () => {
|
||||
expect(resolver.resolve('foo/baz', '/bar')).toEqual('/bar');
|
||||
expect(resolver.resolve('foo/baz/', '/bar')).toEqual('/bar');
|
||||
});
|
||||
});
|
||||
|
||||
describe('corner and error cases', () => {
|
||||
it('should encode URLs before resolving', () => {
|
||||
expect(resolver.resolve('foo/baz', `<p #p>Hello
|
||||
</p>`))
|
||||
.toEqual('foo/%3Cp%20#p%3EHello%0A%20%20%20%20%20%20%20%20%3C/p%3E');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user