Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion perf/dom/compile_perf.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '_perf.dart';

main() => describe('compiler', () {
void main() {
describe('compiler', () {
describe('block instantiation', () {
it('time ', inject((TestBed tb) {
tb.compile(UL_REPEATER);
Expand All @@ -18,6 +19,7 @@ main() => describe('compiler', () {
}));
});
});
}

var UL_REPEATER =
"""
Expand Down
4 changes: 3 additions & 1 deletion test/bootstrap_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ library bootstrap_spec;

import '_specs.dart';

main() => describe('bootstrap', () {
void main() {
describe('bootstrap', () {
BodyElement body = window.document.querySelector('body');

it('should default to whole page', () {
Expand All @@ -27,3 +28,4 @@ main() => describe('bootstrap', () {
expect(body.text).toEqual('{{ignor me}}works');
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import 'package:angular/change_detection/change_detection.dart';
import 'package:angular/change_detection/dirty_checking_change_detector.dart';
import 'dart:collection';

main() => describe('DirtyCheckingChangeDetector', () {
void main() {
describe('DirtyCheckingChangeDetector', () {
DirtyCheckingChangeDetector<String> detector;

beforeEach(() {
Expand Down Expand Up @@ -459,6 +460,7 @@ main() => describe('DirtyCheckingChangeDetector', () {
});
});
});
}

class _User {
String first;
Expand Down
4 changes: 3 additions & 1 deletion test/change_detection/watch_group_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import 'package:angular/change_detection/watch_group.dart';
import 'package:angular/change_detection/dirty_checking_change_detector.dart';
import 'dirty_checking_change_detector_spec.dart' hide main;

main() => describe('WatchGroup', () {
void main() {
describe('WatchGroup', () {
var context;
var watchGrp;
DirtyCheckingChangeDetector changeDetector;
Expand Down Expand Up @@ -641,6 +642,7 @@ main() => describe('WatchGroup', () {
});

});
}

class MyClass {
final Logger logger;
Expand Down
4 changes: 3 additions & 1 deletion test/core/cache_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ library cache_spec;

import '../_specs.dart';

main() => describe('CacheFactory', () {
void main() {
describe('CacheFactory', () {

describe('cache', () {
Cache<String, Object> cache;
Expand Down Expand Up @@ -148,3 +149,4 @@ main() => describe('CacheFactory', () {
}));
});
});
}
4 changes: 3 additions & 1 deletion test/core/core_directive_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ library core_directive_spec;

import '../_specs.dart';

main() => describe('DirectiveMap', () {
void main() {
describe('DirectiveMap', () {

beforeEach(module((Module module) {
module..type(AnnotatedIoComponent);
Expand Down Expand Up @@ -66,6 +67,7 @@ main() => describe('DirectiveMap', () {
});
});
});
}

@NgComponent(
selector: 'annotated-io',
Expand Down
4 changes: 3 additions & 1 deletion test/core/registry_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ library registry_spec;

import '../_specs.dart';

main() => describe('RegistryMap', () {
main() {
describe('RegistryMap', () {
it('should allow for multiple registry keys to be added', () {
var module = new Module()
..type(MyMap)
Expand Down Expand Up @@ -41,6 +42,7 @@ main() => describe('RegistryMap', () {
expect(() => injector.get(MyMap), isNot(throws));
});
});
}

typedef void MyTypedef(String arg);

Expand Down
78 changes: 42 additions & 36 deletions test/core/scope_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ import 'package:angular/change_detection/dirty_checking_change_detector.dart';
import 'dart:async';
import 'dart:math';

main() => describe('scope', () {
void main() {
describe('scope', () {
beforeEach(module((Module module) {
Map context = {};
module.value(GetterCache, new GetterCache({}));
module.type(ChangeDetector, implementedBy: DirtyCheckingChangeDetector);
module.value(Object, context);
module.value(Map, context);
module.type(RootScope);
module.type(_MultiplyFilter);
module.type(_ListHeadFilter);
module.type(_ListTailFilter);
module.type(_SortFilter);
module
..value(GetterCache, new GetterCache({}))
..type(ChangeDetector, implementedBy: DirtyCheckingChangeDetector)
..value(Object, context)
..value(Map, context)
..type(RootScope)
..type(_MultiplyFilter)
..type(_ListHeadFilter)
..type(_ListTailFilter)
..type(_SortFilter);
}));

describe('AST Bridge', () {
Expand Down Expand Up @@ -61,11 +63,12 @@ main() => describe('scope', () {

it('should watch literals', inject((Logger logger, Map context, RootScope rootScope) {
context['a'] = 1;
rootScope.watch('1', (value, previous) => logger(value));
rootScope.watch('"str"', (value, previous) => logger(value));
rootScope.watch('[a, 2, 3]', (value, previous) => logger(value));
rootScope.watch('{a:a, b:2}', (value, previous) => logger(value));
rootScope.digest();
rootScope
..watch('1', (value, previous) => logger(value))
..watch('"str"', (value, previous) => logger(value))
..watch('[a, 2, 3]', (value, previous) => logger(value))
..watch('{a:a, b:2}', (value, previous) => logger(value))
..digest();
expect(logger).toEqual([1, 'str', [1, 2, 3], {'a': 1, 'b': 2}]);
logger.clear();
context['a'] = 3;
Expand Down Expand Up @@ -986,11 +989,12 @@ main() => describe('scope', () {
it(r'should fire watches in order of addition', inject((RootScope rootScope) {
// this is not an external guarantee, just our own sanity
var log = '';
rootScope.watch('a', (a, b) { log += 'a'; });
rootScope.watch('b', (a, b) { log += 'b'; });
rootScope.watch('c', (a, b) { log += 'c'; });
rootScope.context['a'] = rootScope.context['b'] = rootScope.context['c'] = 1;
rootScope.digest();
rootScope
..watch('a', (a, b) { log += 'a'; })
..watch('b', (a, b) { log += 'b'; })
..watch('c', (a, b) { log += 'c'; })
..context['a'] = rootScope.context['b'] = rootScope.context['c'] = 1
..digest();
expect(log).toEqual('abc');
}));

Expand Down Expand Up @@ -1031,10 +1035,11 @@ main() => describe('scope', () {

it(r'should repeat watch cycle while model changes are identified', inject((RootScope rootScope) {
var log = '';
rootScope.watch('c', (v, b) {rootScope.context['d'] = v; log+='c'; });
rootScope.watch('b', (v, b) {rootScope.context['c'] = v; log+='b'; });
rootScope.watch('a', (v, b) {rootScope.context['b'] = v; log+='a'; });
rootScope.digest();
rootScope
..watch('c', (v, b) {rootScope.context['d'] = v; log+='c'; })
..watch('b', (v, b) {rootScope.context['c'] = v; log+='b'; })
..watch('a', (v, b) {rootScope.context['b'] = v; log+='a'; })
..digest();
log = '';
rootScope.context['a'] = 1;
rootScope.digest();
Expand Down Expand Up @@ -1139,19 +1144,19 @@ main() => describe('scope', () {
log.add(val);
};

rootScope.context['nanValue'] = double.NAN;
rootScope.context['nullValue'] = null;
rootScope.context['emptyString'] = '';
rootScope.context['falseValue'] = false;
rootScope.context['numberValue'] = 23;

rootScope.watch('nanValue', logger);
rootScope.watch('nullValue', logger);
rootScope.watch('emptyString', logger);
rootScope.watch('falseValue', logger);
rootScope.watch('numberValue', logger);
rootScope
..context['nanValue'] = double.NAN
..context['nullValue'] = null
..context['emptyString'] = ''
..context['falseValue'] = false
..context['numberValue'] = 23
..watch('nanValue', logger)
..watch('nullValue', logger)
..watch('emptyString', logger)
..watch('falseValue', logger)
..watch('numberValue', logger)
..digest();

rootScope.digest();
expect(log.removeAt(0).isNaN).toEqual(true); //jasmine's toBe and toEqual don't work well with NaNs
expect(log).toEqual([null, '', false, 23]);
log = [];
Expand Down Expand Up @@ -1321,6 +1326,7 @@ main() => describe('scope', () {
});
});
});
}

@NgFilter(name: 'multiply')
class _MultiplyFilter {
Expand Down
51 changes: 27 additions & 24 deletions test/core/templateurl_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class PrefixedUrlRewriter extends UrlRewriter {
call(url) => "PREFIX:$url";
}

main() => describe('template url', () {
void main() {
describe('template url', () {
afterEach(inject((MockHttpBackend backend) {
backend.verifyNoOutstandingRequest();
}));
Expand All @@ -51,9 +52,10 @@ main() => describe('template url', () {
..type(UrlRewriter, implementedBy: PrefixedUrlRewriter);
}));

it('should use the UrlRewriter for both HTML and CSS URLs', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector, NgZone zone,
MockHttpBackend backend, DirectiveMap directives) {
it('should use the UrlRewriter for both HTML and CSS URLs', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Logger log,
Injector injector, NgZone zone, MockHttpBackend backend,
DirectiveMap directives) {

backend
..whenGET('PREFIX:simple.html').respond('<div log="SIMPLE">Simple!</div>')
Expand Down Expand Up @@ -85,9 +87,9 @@ main() => describe('template url', () {
..type(InlineWithCssComponent);
}));

it('should replace element with template from url', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
it('should replace element with template from url', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Logger log,
Injector injector, MockHttpBackend backend, DirectiveMap directives) {
backend.expectGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');

var element = $('<div><simple-url log>ignore</simple-url><div>');
Expand All @@ -102,9 +104,9 @@ main() => describe('template url', () {
expect(log.result()).toEqual('LOG; SIMPLE');
})));

it('should load template from URL once', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
it('should load template from URL once', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Logger log,
Injector injector, MockHttpBackend backend, DirectiveMap directives) {
backend.whenGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');

var element = $(
Expand All @@ -123,9 +125,9 @@ main() => describe('template url', () {
expect(log.result()).toEqual('LOG; LOG; SIMPLE; SIMPLE');
})));

it('should load a CSS file into a style', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
it('should load a CSS file into a style', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Logger log,
Injector injector, MockHttpBackend backend, DirectiveMap directives) {
backend
..expectGET('simple.css').respond('.hello{}')
..expectGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');
Expand All @@ -145,8 +147,8 @@ main() => describe('template url', () {
expect(log.result()).toEqual('LOG; SIMPLE');
})));

it('should load a CSS file with a \$template', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Injector injector,
it('should load a CSS file with a \$template', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
var element = $('<div><inline-with-css log>ignore</inline-with-css><div>');
backend.expectGET('simple.css').respond('.hello{}');
Expand All @@ -157,8 +159,8 @@ main() => describe('template url', () {
expect(renderedText(element)).toEqual('.hello{}inline!');
})));

it('should ignore CSS load errors ', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Injector injector,
it('should ignore CSS load errors ', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
var element = $('<div><inline-with-css log>ignore</inline-with-css><div>');
backend.expectGET('simple.css').respond(500, 'some error');
Expand All @@ -173,8 +175,8 @@ main() => describe('template url', () {
'inline!');
})));

it('should load a CSS with no template', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Injector injector,
it('should load a CSS with no template', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
var element = $('<div><only-css log>ignore</only-css><div>');
backend.expectGET('simple.css').respond('.hello{}');
Expand All @@ -185,8 +187,8 @@ main() => describe('template url', () {
expect(renderedText(element)).toEqual('.hello{}');
})));

it('should load the CSS before the template is loaded', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Injector injector,
it('should load the CSS before the template is loaded', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
backend
..expectGET('simple.css').respond('.hello{}')
Expand All @@ -208,9 +210,9 @@ main() => describe('template url', () {
..type(HtmlAndMultipleCssComponent);
}));

it('should load multiple CSS files into a style', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
it('should load multiple CSS files into a style', async(inject(
(Http $http, Compiler $compile, Scope $rootScope, Logger log,
Injector injector, MockHttpBackend backend, DirectiveMap directives) {
backend
..expectGET('simple.css').respond('.hello{}')
..expectGET('another.css').respond('.world{}')
Expand All @@ -232,3 +234,4 @@ main() => describe('template url', () {
})));
});
});
}
4 changes: 3 additions & 1 deletion test/core/zone_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import '../_specs.dart';

import 'dart:async';

main() => describe('zone', () {
void main() {
describe('zone', () {
var zone;
var exceptionHandler;
beforeEach(module((Module module) {
Expand Down Expand Up @@ -359,3 +360,4 @@ main() => describe('zone', () {
})).toThrow('ssertion'); // Support both dart2js and the VM with half a word.
});
});
}
Loading