feat: adjust formatting for clang-format v1.0.19.

This commit is contained in:
Martin Probst 2015-06-12 07:50:45 -07:00
parent 1c2abbc61d
commit a6e7123995
50 changed files with 363 additions and 350 deletions

View File

@ -1,12 +1,6 @@
export class Test {
firstItem;
constructor() {
this.doStuff();
}
otherMethod() {
}
doStuff() {
}
constructor() { this.doStuff(); }
otherMethod() {}
doStuff() {}
}

View File

@ -20,16 +20,12 @@ export class MyClass {
* Create a new MyClass
* @param {String} name The name to say hello to
*/
constructor(name) {
this.message = 'hello ' + name;
}
constructor(name) { this.message = 'hello ' + name; }
/**
* Return a greeting message
*/
greet() {
return this.message;
}
greet() { return this.message; }
}
/**

View File

@ -3,8 +3,20 @@ import {BindingRecord} from './binding_record';
import {DirectiveIndex} from './directive_record';
export enum RecordType {
SELF, CONST, PRIMITIVE_OP, PROPERTY, LOCAL, INVOKE_METHOD, INVOKE_CLOSURE, KEYED_ACCESS, PIPE,
BINDING_PIPE, INTERPOLATE, SAFE_PROPERTY, SAFE_INVOKE_METHOD, DIRECTIVE_LIFECYCLE
SELF,
CONST,
PRIMITIVE_OP,
PROPERTY,
LOCAL,
INVOKE_METHOD,
INVOKE_CLOSURE,
KEYED_ACCESS,
PIPE,
BINDING_PIPE,
INTERPOLATE,
SAFE_PROPERTY,
SAFE_INVOKE_METHOD,
DIRECTIVE_LIFECYCLE
}
export class ProtoRecord {

View File

@ -348,15 +348,18 @@ function _createProtoElementInjector(binderIndex, parentPeiWithDistance, renderE
}
function _createElementBinder(protoView, boundElementIndex, renderElementBinder,
protoElementInjector, componentDirectiveBinding, directiveBindings): ElementBinder {
protoElementInjector, componentDirectiveBinding,
directiveBindings): ElementBinder {
var parent = null;
if (renderElementBinder.parentIndex !== -1) {
parent = protoView.elementBinders[renderElementBinder.parentIndex];
}
var directiveVariableBindings = createDirectiveVariableBindings(renderElementBinder, directiveBindings);
var elBinder = protoView.bindElement(parent, renderElementBinder.distanceToParent,
protoElementInjector, directiveVariableBindings, componentDirectiveBinding);
var directiveVariableBindings =
createDirectiveVariableBindings(renderElementBinder, directiveBindings);
var elBinder =
protoView.bindElement(parent, renderElementBinder.distanceToParent, protoElementInjector,
directiveVariableBindings, componentDirectiveBinding);
protoView.bindEvent(renderElementBinder.eventBindings, boundElementIndex, -1);
// variables
// The view's locals needs to have a full set of variable names at construction time
@ -369,7 +372,8 @@ function _createElementBinder(protoView, boundElementIndex, renderElementBinder,
return elBinder;
}
export function createDirectiveVariableBindings(renderElementBinder:renderApi.ElementBinder,
export function createDirectiveVariableBindings(
renderElementBinder: renderApi.ElementBinder,
directiveBindings: List<DirectiveBinding>): Map<String, number> {
var directiveVariableBindings = MapWrapper.create();
MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => {
@ -388,7 +392,8 @@ function _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, e
if (_directiveExportAs(directive) == exportAs) {
if (isPresent(matchedDirective)) {
throw new BaseException(`More than one directive have exportAs = '${exportAs}'. Directives: [${matchedDirective.displayName}, ${directive.displayName}]`);
throw new BaseException(
`More than one directive have exportAs = '${exportAs}'. Directives: [${matchedDirective.displayName}, ${directive.displayName}]`);
}
matchedDirectiveIndex = i;
@ -405,7 +410,8 @@ function _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, e
function _directiveExportAs(directive): string {
var directiveExportAs = directive.metadata.exportAs;
if (isBlank(directiveExportAs) && directive.metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
if (isBlank(directiveExportAs) &&
directive.metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
return "$implicit";
} else {
return directiveExportAs;

View File

@ -143,9 +143,7 @@ export class NgZone {
errorHandling = StringMapWrapper.merge(Zone.longStackTraceZone,
{onError: function(e) { ngZone._onError(this, e) }});
} else {
errorHandling = {
onError: function(e) { ngZone._onError(this, e) }
};
errorHandling = {onError: function(e) { ngZone._onError(this, e) }};
}
return zone.fork(errorHandling)

View File

@ -11,8 +11,7 @@ import {createTestInjector, FunctionWithParamTokens, inject} from './test_inject
export {inject} from './test_injector';
export function proxy() {
}
export function proxy() {}
var _global: jasmine.GlobalPolluter = <any>(typeof window === 'undefined' ? global : window);

View File

@ -42,7 +42,8 @@ export function el(html: string) {
return DOM.firstChild(DOM.content(DOM.createTemplate(html)));
}
var _RE_SPECIAL_CHARS = ['-', '[', ']', '/', '{', '}', '\\', '(', ')', '*', '+', '?', '.', '^', '$', '|'];
var _RE_SPECIAL_CHARS =
['-', '[', ']', '/', '{', '}', '\\', '(', ')', '*', '+', '?', '.', '^', '$', '|'];
var _ESCAPE_RE = RegExpWrapper.create(`[\\${_RE_SPECIAL_CHARS.join('\\')}]`);
export function containsRegexp(input: string): RegExp {
return RegExpWrapper.create(

View File

@ -89,9 +89,12 @@ export class TestDefinition {
*/
export function getAllDefinitions(): List<TestDefinition> {
var allDefs = _availableDefinitions;
allDefs = ListWrapper.concat(allDefs, StringMapWrapper.keys(_ExpressionWithLocals.availableDefinitions));
allDefs = ListWrapper.concat(allDefs, StringMapWrapper.keys(_ExpressionWithMode.availableDefinitions));
allDefs = ListWrapper.concat(allDefs, StringMapWrapper.keys(_DirectiveUpdating.availableDefinitions));
allDefs = ListWrapper.concat(allDefs,
StringMapWrapper.keys(_ExpressionWithLocals.availableDefinitions));
allDefs =
ListWrapper.concat(allDefs, StringMapWrapper.keys(_ExpressionWithMode.availableDefinitions));
allDefs =
ListWrapper.concat(allDefs, StringMapWrapper.keys(_DirectiveUpdating.availableDefinitions));
return ListWrapper.map(allDefs, (id) => getDefinition(id));
}

View File

@ -87,7 +87,8 @@ export function main() {
function _createWithoutHydrate(expression: string) {
var dispatcher = new TestDispatcher();
var registry = null;
var cd = _getProtoChangeDetector(getDefinition(expression).cdDef, registry).instantiate(dispatcher);
var cd = _getProtoChangeDetector(getDefinition(expression).cdDef, registry)
.instantiate(dispatcher);
return new _ChangeDetectorAndDispatcher(cd, dispatcher);
}
@ -334,7 +335,8 @@ export function main() {
it('should happen directly, without invoking the dispatcher', () => {
var val = _createWithoutHydrate('directNoDispatcher');
val.changeDetector.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1], []));
val.changeDetector.hydrate(_DEFAULT_CONTEXT, null,
new FakeDirectives([directive1], []));
val.changeDetector.detectChanges();
expect(val.dispatcher.loggedValues).toEqual([]);
expect(directive1.a).toEqual(42);
@ -465,11 +467,11 @@ export function main() {
var orderOfOperations = [];
var directiveInShadowDom = null;
directiveInShadowDom =
new TestDirective(() => { ListWrapper.push(orderOfOperations, directiveInShadowDom); });
directiveInShadowDom = new TestDirective(
() => { ListWrapper.push(orderOfOperations, directiveInShadowDom); });
var parentDirective = null;
parentDirective =
new TestDirective(() => { ListWrapper.push(orderOfOperations, parentDirective); });
parentDirective = new TestDirective(
() => { ListWrapper.push(orderOfOperations, parentDirective); });
parent.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([parentDirective], []));
child.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directiveInShadowDom], []));
@ -594,8 +596,7 @@ export function main() {
});
describe('mode', () => {
it('should set the mode to CHECK_ALWAYS when the default change detection is used',
() => {
it('should set the mode to CHECK_ALWAYS when the default change detection is used', () => {
var cd = _createWithoutHydrate('emptyUsingDefaultStrategy').changeDetector;
expect(cd.mode).toEqual(null);

View File

@ -31,9 +31,7 @@ export function main() {
function normalize(obj: string): string { return StringWrapper.replace(obj, regNewLine, ''); }
beforeEach(() => {
inceptionObj = {
dream: {dream: {dream: 'Limbo'}}
};
inceptionObj = {dream: {dream: {dream: 'Limbo'}}};
inceptionObjString = "{\n" + " \"dream\": {\n" + " \"dream\": {\n" +
" \"dream\": \"Limbo\"\n" + " }\n" + " }\n" + "}";

View File

@ -315,9 +315,8 @@ export function main() {
var nestedProtoView = createProtoView();
var compiler = createCompiler([
createRenderProtoView([
createRenderViewportElementBinder(
createRenderProtoView([createRenderComponentElementBinder(0)],
renderApi.ViewType.EMBEDDED))
createRenderViewportElementBinder(createRenderProtoView(
[createRenderComponentElementBinder(0)], renderApi.ViewType.EMBEDDED))
]),
createRenderProtoView()
],

View File

@ -1488,8 +1488,7 @@ class DirectiveListeningDomEvent {
}
var globalCounter = 0;
@Directive(
{selector: '[listenerother]', host: {'(window:domEvent)': 'onEvent($event.type)'}})
@Directive({selector: '[listenerother]', host: {'(window:domEvent)': 'onEvent($event.type)'}})
@Injectable()
class DirectiveListeningDomEventOther {
eventType: string;

View File

@ -142,7 +142,9 @@ class NeedsQuery {
@Injectable()
class NeedsQueryDesc {
query: QueryList<TextDirective>;
constructor(@Query(TextDirective, {descendants: true}) query: QueryList<TextDirective>) { this.query = query; }
constructor(@Query(TextDirective, {descendants: true}) query: QueryList<TextDirective>) {
this.query = query;
}
}
@Component({selector: 'my-comp'})

View File

@ -205,21 +205,15 @@ function commonTests() {
_zone.initCallbacks({
onTurnDone: () => {
_log.add('onTurnDone:started');
_zone.run(() => _log.add('nested run'))
_log.add('onTurnDone:finished');
_zone.run(() => _log.add('nested run')) _log.add('onTurnDone:finished');
}
});
macroTask(() => {
_zone.run(() => {
_log.add('start run');
});
});
macroTask(() => { _zone.run(() => { _log.add('start run'); }); });
macroTask(() => {
expect(_log.result())
.toEqual(
'start run; onTurnDone:started; nested run; onTurnDone:finished');
.toEqual('start run; onTurnDone:started; nested run; onTurnDone:finished');
async.done();
}, 50);
}));

View File

@ -92,10 +92,7 @@ export function main() {
view.detectChanges();
expect(view.rootNodes[0].className).toEqual('ng-binding foo');
view.context.expr = {
'foo': false,
'bar': true
};
view.context.expr = {'foo': false, 'bar': true};
view.detectChanges();
expect(view.rootNodes[0].className).toEqual('ng-binding bar');

View File

@ -39,7 +39,8 @@ export function main() {
var baseResponse;
var sampleObserver;
beforeEach(() => {
injector = Injector.resolveAndCreate([MockBackend, bind(Http).toFactory(HttpFactory, [MockBackend])]);
injector = Injector.resolveAndCreate(
[MockBackend, bind(Http).toFactory(HttpFactory, [MockBackend])]);
http = injector.get(Http);
backend = injector.get(MockBackend);
baseResponse = new Response('base response');

View File

@ -84,10 +84,8 @@ export function main() {
// clang-format on
});
it("should throw when more than 20 arguments", () => {
expect(() => reflector.factory(TestObjWith21Args))
.toThrowError();
});
it("should throw when more than 20 arguments",
() => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); });
it("should return a registered factory if available", () => {
reflector.registerType(TestObj, {"factory": () => "fake"});
@ -195,65 +193,47 @@ export function main() {
class TestObjWith00Args {
args: List<any>;
constructor() {
this.args = [];
}
constructor() { this.args = []; }
}
class TestObjWith01Args {
args: List<any>;
constructor(a1) {
this.args = [a1];
}
constructor(a1) { this.args = [a1]; }
}
class TestObjWith02Args {
args: List<any>;
constructor(a1, a2) {
this.args = [a1, a2];
}
constructor(a1, a2) { this.args = [a1, a2]; }
}
class TestObjWith03Args {
args: List<any>;
constructor(a1, a2, a3) {
this.args = [a1, a2, a3];
}
constructor(a1, a2, a3) { this.args = [a1, a2, a3]; }
}
class TestObjWith04Args {
args: List<any>;
constructor(a1, a2, a3, a4) {
this.args = [a1, a2, a3, a4];
}
constructor(a1, a2, a3, a4) { this.args = [a1, a2, a3, a4]; }
}
class TestObjWith05Args {
args: List<any>;
constructor(a1, a2, a3, a4, a5) {
this.args = [a1, a2, a3, a4, a5];
}
constructor(a1, a2, a3, a4, a5) { this.args = [a1, a2, a3, a4, a5]; }
}
class TestObjWith06Args {
args: List<any>;
constructor(a1, a2, a3, a4, a5, a6) {
this.args = [a1, a2, a3, a4, a5, a6];
}
constructor(a1, a2, a3, a4, a5, a6) { this.args = [a1, a2, a3, a4, a5, a6]; }
}
class TestObjWith07Args {
args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7) {
this.args = [a1, a2, a3, a4, a5, a6, a7];
}
constructor(a1, a2, a3, a4, a5, a6, a7) { this.args = [a1, a2, a3, a4, a5, a6, a7]; }
}
class TestObjWith08Args {
args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7, a8) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8];
}
constructor(a1, a2, a3, a4, a5, a6, a7, a8) { this.args = [a1, a2, a3, a4, a5, a6, a7, a8]; }
}
class TestObjWith09Args {
@ -328,21 +308,48 @@ class TestObjWith18Args {
class TestObjWith19Args {
args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19];
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
a19) {
this.args =
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19];
}
}
class TestObjWith20Args {
args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20];
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
a20) {
this.args =
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20];
}
}
class TestObjWith21Args {
args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21) {
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21];
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
a20, a21) {
this.args = [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17,
a18,
a19,
a20,
a21
];
}
}

View File

@ -252,10 +252,8 @@ var someDirectiveWithHostAttributes = DirectiveMetadata.create({
host: MapWrapper.createFromStringMap({'attr_name': 'attr_val', 'class': 'foo bar'})
});
var someDirectiveWithEvents = DirectiveMetadata.create({
selector: '[some-decor-events]',
host: MapWrapper.createFromStringMap({'(click)': 'doIt()'})
});
var someDirectiveWithEvents = DirectiveMetadata.create(
{selector: '[some-decor-events]', host: MapWrapper.createFromStringMap({'(click)': 'doIt()'})});
var someDirectiveWithHostActions = DirectiveMetadata.create({
selector: '[some-decor-host-actions]',

View File

@ -42,8 +42,7 @@ export function main() {
var pipeline = new CompilePipeline([
new MockStep((parent, current, control) => {
if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) {
current.inheritedProtoView =
new ProtoViewBuilder(current.element, ViewType.EMBEDDED);
current.inheritedProtoView = new ProtoViewBuilder(current.element, ViewType.EMBEDDED);
}
})
]);

View File

@ -26,10 +26,14 @@ export function main() {
});
var map = directiveMetadataToMap(someComponent);
expect(MapWrapper.get(map, 'compileChildren')).toEqual(false);
expect(MapWrapper.get(map, 'hostListeners')).toEqual(MapWrapper.createFromPairs([['LKey', 'LVal']]));
expect(MapWrapper.get(map, 'hostProperties')).toEqual(MapWrapper.createFromPairs([['PKey', 'PVal']]));
expect(MapWrapper.get(map, 'hostActions')).toEqual(MapWrapper.createFromPairs([['AcKey', 'AcVal']]));
expect(MapWrapper.get(map, 'hostAttributes')).toEqual(MapWrapper.createFromPairs([['AtKey', 'AtVal']]));
expect(MapWrapper.get(map, 'hostListeners'))
.toEqual(MapWrapper.createFromPairs([['LKey', 'LVal']]));
expect(MapWrapper.get(map, 'hostProperties'))
.toEqual(MapWrapper.createFromPairs([['PKey', 'PVal']]));
expect(MapWrapper.get(map, 'hostActions'))
.toEqual(MapWrapper.createFromPairs([['AcKey', 'AcVal']]));
expect(MapWrapper.get(map, 'hostAttributes'))
.toEqual(MapWrapper.createFromPairs([['AtKey', 'AtVal']]));
expect(MapWrapper.get(map, 'id')).toEqual('someComponent');
expect(MapWrapper.get(map, 'properties')).toEqual(['propKey: propVal']);
expect(MapWrapper.get(map, 'readAttributes')).toEqual(['read1', 'read2']);

View File

@ -75,7 +75,8 @@ export function main() {
tb.compileAll([
someComponent,
new ViewDefinition({
componentId: 'someComponent', template: '<some-comp> <!-- comment -->\n </some-comp>',
componentId: 'someComponent',
template: '<some-comp> <!-- comment -->\n </some-comp>',
directives: [someComponent]
})
])

View File

@ -97,12 +97,14 @@ export function main() {
expect(DOM.getText(styleElement)).not.toEqual(DOM.getText(styleElement2));
});
it('should move the style element to the style host when @imports are present', inject([AsyncTestCompleter], (async) => {
it('should move the style element to the style host when @imports are present',
inject([AsyncTestCompleter], (async) => {
xhr.reply('http://base/one.css', '.one {}');
var compileElement = el('<div><style>@import "one.css";</style></div>');
var styleElement = DOM.firstChild(compileElement);
var stylePromise = strategy.processStyleElement('someComponent', 'http://base', styleElement);
var stylePromise =
strategy.processStyleElement('someComponent', 'http://base', styleElement);
stylePromise.then((_) => {
expect(compileElement).toHaveText('');

View File

@ -43,8 +43,8 @@ export function main() {
styleInliner, styleUrlResolver, null),
[StyleInliner, StyleUrlResolver]),
"unscoped": bind(ShadowDomStrategy)
.toFactory((styleUrlResolver) => new EmulatedUnscopedShadowDomStrategy(
styleUrlResolver, null),
.toFactory((styleUrlResolver) =>
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, null),
[StyleUrlResolver])
};
if (DOM.supportsNativeShadowDOM()) {
@ -398,14 +398,14 @@ export function main() {
}
var mainDir =
DirectiveMetadata.create({selector: 'main', id: 'main', type: DirectiveMetadata.COMPONENT_TYPE});
var mainDir = DirectiveMetadata.create(
{selector: 'main', id: 'main', type: DirectiveMetadata.COMPONENT_TYPE});
var simple = DirectiveMetadata.create(
{selector: 'simple', id: 'simple', type: DirectiveMetadata.COMPONENT_TYPE});
var empty =
DirectiveMetadata.create({selector: 'empty', id: 'empty', type: DirectiveMetadata.COMPONENT_TYPE});
var empty = DirectiveMetadata.create(
{selector: 'empty', id: 'empty', type: DirectiveMetadata.COMPONENT_TYPE});
var dynamicComponent = DirectiveMetadata.create(
{selector: 'dynamic', id: 'dynamic', type: DirectiveMetadata.COMPONENT_TYPE});
@ -425,11 +425,11 @@ var outerWithIndirectNestedComponent = DirectiveMetadata.create({
type: DirectiveMetadata.COMPONENT_TYPE
});
var outerComponent =
DirectiveMetadata.create({selector: 'outer', id: 'outer', type: DirectiveMetadata.COMPONENT_TYPE});
var outerComponent = DirectiveMetadata.create(
{selector: 'outer', id: 'outer', type: DirectiveMetadata.COMPONENT_TYPE});
var innerComponent =
DirectiveMetadata.create({selector: 'inner', id: 'inner', type: DirectiveMetadata.COMPONENT_TYPE});
var innerComponent = DirectiveMetadata.create(
{selector: 'inner', id: 'inner', type: DirectiveMetadata.COMPONENT_TYPE});
var innerInnerComponent = DirectiveMetadata.create(
{selector: 'innerinner', id: 'innerinner', type: DirectiveMetadata.COMPONENT_TYPE});

View File

@ -33,14 +33,16 @@ export function main() {
});
if (!IS_DARTIUM) {
it('should use a noop setter if the property did not exist when the setter was created', () => {
it('should use a noop setter if the property did not exist when the setter was created',
() => {
var setterFn = setterFactory.createSetter(div, false, 'someProp');
div.someProp = '';
setterFn(div, 'Hello');
expect(div.someProp).toEqual('');
});
it('should use a noop setter if the property did not exist when the setter was created for ng components', () => {
it('should use a noop setter if the property did not exist when the setter was created for ng components',
() => {
var ce = el('<some-ce></some-ce>');
var setterFn = setterFactory.createSetter(ce, true, 'someProp');
ce.someProp = '';
@ -48,7 +50,8 @@ export function main() {
expect(ce.someProp).toEqual('');
});
it('should set the property for custom elements even if it was not present when the setter was created', () => {
it('should set the property for custom elements even if it was not present when the setter was created',
() => {
var ce = el('<some-ce></some-ce>');
var setterFn = setterFactory.createSetter(ce, false, 'someProp');
ce.someProp = '';

View File

@ -49,24 +49,21 @@ export function main() {
}
function createElementBinder(parentIndex: number = 0, distanceToParent: number = 1) {
return new ElementBinder({parentIndex: parentIndex, distanceToParent:distanceToParent, textNodeIndices:[]});
return new ElementBinder(
{parentIndex: parentIndex, distanceToParent: distanceToParent, textNodeIndices: []});
}
describe('getDirectParentElement', () => {
it('should return the DomElement of the direct parent', () => {
var pv = createProtoView(
[createElementBinder(), createElementBinder(0, 1)]);
var pv = createProtoView([createElementBinder(), createElementBinder(0, 1)]);
var view = createView(pv, 2);
expect(view.getDirectParentElement(1)).toBe(view.boundElements[0]);
});
it('should return null if the direct parent is not bound', () => {
var pv = createProtoView([
createElementBinder(),
createElementBinder(),
createElementBinder(0,2)
]);
var pv = createProtoView(
[createElementBinder(), createElementBinder(), createElementBinder(0, 2)]);
var view = createView(pv, 3);
expect(view.getDirectParentElement(2)).toBe(null);
});

View File

@ -25,7 +25,8 @@ export function main() {
registry.config(rootHostComponent, {'path': '/', 'component': DummyCompA});
registry.config(rootHostComponent, {'path': '/test', 'component': DummyCompB});
registry.recognize('/test', rootHostComponent).then((instruction) => {
registry.recognize('/test', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyCompB);
async.done();
});
@ -35,7 +36,8 @@ export function main() {
registry.config(rootHostComponent, {'path': '/:site', 'component': DummyCompB});
registry.config(rootHostComponent, {'path': '/home', 'component': DummyCompA});
registry.recognize('/home', rootHostComponent).then((instruction) => {
registry.recognize('/home', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyCompA);
async.done();
});
@ -45,7 +47,8 @@ export function main() {
registry.config(rootHostComponent, {'path': '/:site', 'component': DummyCompA});
registry.config(rootHostComponent, {'path': '/*site', 'component': DummyCompB});
registry.recognize('/home', rootHostComponent).then((instruction) => {
registry.recognize('/home', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyCompA);
async.done();
});
@ -55,7 +58,8 @@ export function main() {
registry.config(rootHostComponent, {'path': '/:first/*rest', 'component': DummyCompA});
registry.config(rootHostComponent, {'path': '/*all', 'component': DummyCompB});
registry.recognize('/some/path', rootHostComponent).then((instruction) => {
registry.recognize('/some/path', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyCompA);
async.done();
});
@ -65,17 +69,22 @@ export function main() {
registry.config(rootHostComponent, {'path': '/first/:second', 'component': DummyCompA});
registry.config(rootHostComponent, {'path': '/:first/:second', 'component': DummyCompB});
registry.recognize('/first/second', rootHostComponent).then((instruction) => {
registry.recognize('/first/second', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyCompA);
async.done();
});
}));
it('should prefer routes with static segments before dynamic segments', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/first/second/:third', 'component': DummyCompB});
registry.config(rootHostComponent, {'path': '/first/:second/third', 'component': DummyCompA});
it('should prefer routes with static segments before dynamic segments',
inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent,
{'path': '/first/second/:third', 'component': DummyCompB});
registry.config(rootHostComponent,
{'path': '/first/:second/third', 'component': DummyCompA});
registry.recognize('/first/second/third', rootHostComponent).then((instruction) => {
registry.recognize('/first/second/third', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyCompB);
async.done();
});
@ -84,27 +93,34 @@ export function main() {
it('should match the full URL using child components', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/first', 'component': DummyParentComp});
registry.recognize('/first/second', rootHostComponent).then((instruction) => {
registry.recognize('/first/second', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyParentComp);
expect(instruction.child.component).toBe(DummyCompB);
async.done();
});
}));
it('should match the URL using async child components', inject([AsyncTestCompleter], (async) => {
it('should match the URL using async child components',
inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/first', 'component': DummyAsyncComp});
registry.recognize('/first/second', rootHostComponent).then((instruction) => {
registry.recognize('/first/second', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyAsyncComp);
expect(instruction.child.component).toBe(DummyCompB);
async.done();
});
}));
it('should match the URL using an async parent component', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/first', 'component': {'loader': AsyncParentLoader, 'type': 'loader'} });
it('should match the URL using an async parent component',
inject([AsyncTestCompleter], (async) => {
registry.config(
rootHostComponent,
{'path': '/first', 'component': {'loader': AsyncParentLoader, 'type': 'loader'}});
registry.recognize('/first/second', rootHostComponent).then((instruction) => {
registry.recognize('/first/second', rootHostComponent)
.then((instruction) => {
expect(instruction.component).toBe(DummyParentComp);
expect(instruction.child.component).toBe(DummyCompB);
async.done();
@ -113,11 +129,14 @@ export function main() {
it('should throw when a config does not have a component or redirectTo property', () => {
expect(() => registry.config(rootHostComponent, {'path': '/some/path'}))
.toThrowError('Route config should contain exactly one \'component\', or \'redirectTo\' property');
.toThrowError(
'Route config should contain exactly one \'component\', or \'redirectTo\' property');
});
it('should throw when a config has an invalid component type', () => {
expect(() => registry.config(rootHostComponent, {'path': '/some/path', 'component': { 'type': 'intentionallyWrongComponentType' } }))
expect(() => registry.config(
rootHostComponent,
{'path': '/some/path', 'component': {'type': 'intentionallyWrongComponentType'}}))
.toThrowError('Invalid component type \'intentionallyWrongComponentType\'');
});
});
@ -131,10 +150,9 @@ function AsyncChildLoader() {
return PromiseWrapper.resolve(DummyCompB);
}
@RouteConfig([
{ 'path': '/second', 'component': { 'loader': AsyncChildLoader, 'type': 'loader' } }
])
class DummyAsyncComp {}
@RouteConfig([{'path': '/second', 'component': {'loader': AsyncChildLoader, 'type': 'loader'}}])
class DummyAsyncComp {
}
class DummyCompA {}
class DummyCompB {}

View File

@ -49,12 +49,7 @@ angular.module('app', [])
for (var i = 0; i < totalRows; i++) {
data[i] = [];
for (var j = 0; j < totalColumns; j++) {
data[i][j] = {
i: i,
j: j,
iFn: iGetter,
jFn: jGetter
};
data[i][j] = {i: i, j: j, iFn: iGetter, jFn: jGetter};
}
}
})

View File

@ -72,9 +72,7 @@ class MockMetric extends Metric {
endMeasure(restart: boolean): Promise<StringMap<string, any>> {
var result = {};
result[this._id] = {
'restart': restart
};
result[this._id] = {'restart': restart};
return PromiseWrapper.resolve(result);
}

View File

@ -18,9 +18,8 @@ export function main() {
var reporter;
var log;
function createReporter({columnWidth = null, sampleId = null, descriptions = null, metrics = null}:{
columnWidth?, sampleId?, descriptions?, metrics?
}) {
function createReporter({columnWidth = null, sampleId = null, descriptions = null,
metrics = null}: {columnWidth?, sampleId?, descriptions?, metrics?}) {
log = [];
if (isBlank(descriptions)) {
descriptions = [];

View File

@ -31,10 +31,7 @@ export function main() {
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(1234)),
bind(Options.WRITE_FILE)
.toValue((filename, content) => {
loggedFile = {
'filename': filename,
'content': content
};
loggedFile = {'filename': filename, 'content': content};
return PromiseWrapper.resolve(null);
})
];

View File

@ -34,8 +34,7 @@ if (typeof _global['$traceurRuntime'] === 'object') {
}
Object.keys(primitives).forEach(function(name) { primitives[name].__assertName = name; });
export function proxy() {
}
export function proxy() {}
function assertArgumentTypes(...params) {
var actual, type;

View File

@ -9,9 +9,7 @@ import {DiffingFlatten} from './broccoli-flatten';
describe('Flatten', () => {
afterEach(() => mockfs.restore());
function flatten(inputPaths) {
return new DiffingFlatten(inputPaths, 'output', null);
}
function flatten(inputPaths) { return new DiffingFlatten(inputPaths, 'output', null); }
function read(path) { return fs.readFileSync(path, {encoding: "utf-8"}); }
function rm(path) { return fs.unlinkSync(path); }
@ -59,9 +57,8 @@ describe('Flatten', () => {
'input': {
'dir1': {
'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
'subdir-1': {
'file-1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
},
'subdir-1':
{'file-1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})},
'empty-dir': {}
},
},
@ -71,7 +68,7 @@ describe('Flatten', () => {
let differ = new TreeDiffer('testLabel', 'input');
let flattenedTree = flatten('input');
expect(() => flattenedTree.rebuild(differ.diffTree())).
toThrowError("Duplicate file 'file-1.txt' found in path 'dir1/subdir-1/file-1.txt'");
expect(() => flattenedTree.rebuild(differ.diffTree()))
.toThrowError("Duplicate file 'file-1.txt' found in path 'dir1/subdir-1/file-1.txt'");
});
});

View File

@ -11,7 +11,11 @@ interface LodashRendererOptions {
files?: string[];
}
const kDefaultOptions: LodashRendererOptions = {encoding: 'utf-8', context: {}, files: []};
const kDefaultOptions: LodashRendererOptions = {
encoding: 'utf-8',
context: {},
files: []
};
/**

View File

@ -54,8 +54,8 @@ describe('MergeTrees', () => {
mockfs(testDir);
let treeDiffer = MakeTreeDiffers(['tree1', 'tree2', 'tree3']);
let treeMerger = mergeTrees(['tree1', 'tree2', 'tree3'], 'dest', {});
expect(() => treeMerger.rebuild(treeDiffer.diffTrees())).
toThrowError("`overwrite` option is required for handling duplicates.");
expect(() => treeMerger.rebuild(treeDiffer.diffTrees()))
.toThrowError("`overwrite` option is required for handling duplicates.");
testDir = {
'tree1': {'foo.js': mockfs.file({content: 'tree1/foo.js content', mtime: new Date(1000)})},
@ -81,7 +81,7 @@ describe('MergeTrees', () => {
testDir.tree2['foo.js'] = mockfs.file({content: 'tree2/foo.js content', mtime: new Date(1000)});
mockfs(testDir);
expect(() => treeMerger.rebuild(treeDiffer.diffTrees())).
toThrowError("`overwrite` option is required for handling duplicates.");
expect(() => treeMerger.rebuild(treeDiffer.diffTrees()))
.toThrowError("`overwrite` option is required for handling duplicates.");
});
});

View File

@ -10,7 +10,9 @@ import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-br
type FileRegistry = ts.Map<{version: number}>;
const FS_OPTS = {encoding: 'utf-8'};
const FS_OPTS = {
encoding: 'utf-8'
};
/**

View File

@ -30,8 +30,7 @@ describe('TreeDiffer', () => {
let diffResult = differ.diffTree();
expect(diffResult.addedPaths)
.toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
expect(diffResult.addedPaths).toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
expect(diffResult.changedPaths).toEqual([]);
expect(diffResult.removedPaths).toEqual([]);
@ -83,8 +82,7 @@ describe('TreeDiffer', () => {
let diffResult = differ.diffTree();
expect(diffResult.addedPaths)
.toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
expect(diffResult.addedPaths).toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
// change two files
testDir['dir1']['file-1.txt'] = mockfs.file({content: 'new content', mtime: new Date(1000)});
@ -129,8 +127,7 @@ describe('TreeDiffer', () => {
let diffResult = differ.diffTree();
expect(diffResult.addedPaths)
.toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
expect(diffResult.addedPaths).toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
// change two files
testDir['orig_path']['file-1.txt'] =
@ -257,8 +254,7 @@ describe('TreeDiffer', () => {
let diffResult = differ.diffTree();
expect(diffResult.addedPaths)
.toEqual(['file-1.cs', 'file-1.ts', 'file-1d.cs', 'file-3.ts']);
expect(diffResult.addedPaths).toEqual(['file-1.cs', 'file-1.ts', 'file-1d.cs', 'file-3.ts']);
// change two files
testDir['dir1']['file-1.ts'] = mockfs.file({content: 'new content', mtime: new Date(1000)});

View File

@ -133,10 +133,7 @@ module.exports = function makeBrowserTree(options, destinationPath) {
// Get scripts for each benchmark or example
let servingTrees = kServedPaths.reduce(getServedFunnels, []);
function getServedFunnels(funnels, destDir) {
let options = {
srcDir: '/',
destDir: destDir
};
let options = {srcDir: '/', destDir: destDir};
funnels.push(new Funnel(vendorScriptsTree, options));
if (destDir.indexOf('benchmarks') > -1) {
funnels.push(new Funnel(vendorScripts_benchmark, options));