2010-07-15 21:16:04 +00:00
|
|
|
beforeEach(function(){
|
|
|
|
|
compileCache = {};
|
|
|
|
|
});
|
|
|
|
|
|
2010-02-09 22:59:24 +00:00
|
|
|
describe('Angular', function(){
|
2010-03-30 03:25:42 +00:00
|
|
|
xit('should fire on updateEvents', function(){
|
2010-02-09 22:59:24 +00:00
|
|
|
var onUpdateView = jasmine.createSpy();
|
|
|
|
|
var scope = angular.compile("<div></div>", { onUpdateView: onUpdateView });
|
|
|
|
|
expect(onUpdateView).wasNotCalled();
|
2010-03-30 03:25:42 +00:00
|
|
|
scope.$init();
|
|
|
|
|
scope.$eval();
|
2010-02-09 22:59:24 +00:00
|
|
|
expect(onUpdateView).wasCalled();
|
|
|
|
|
});
|
2010-03-15 21:36:50 +00:00
|
|
|
});
|
|
|
|
|
|
2010-10-19 04:20:47 +00:00
|
|
|
describe('case', function(){
|
|
|
|
|
it('should change case', function(){
|
|
|
|
|
expect(lowercase('ABC90')).toEqual('abc90');
|
|
|
|
|
expect(manualLowercase('ABC90')).toEqual('abc90');
|
|
|
|
|
expect(uppercase('abc90')).toEqual('ABC90');
|
|
|
|
|
expect(manualUppercase('abc90')).toEqual('ABC90');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2010-03-15 21:36:50 +00:00
|
|
|
describe("copy", function(){
|
|
|
|
|
it("should return same object", function (){
|
|
|
|
|
var obj = {};
|
|
|
|
|
var arr = [];
|
|
|
|
|
assertSame(obj, copy({}, obj));
|
|
|
|
|
assertSame(arr, copy([], arr));
|
|
|
|
|
});
|
|
|
|
|
|
2010-10-13 19:47:10 +00:00
|
|
|
it("should copy Date", function(){
|
|
|
|
|
var date = new Date(123);
|
|
|
|
|
expect(copy(date) instanceof Date).toBeTruthy();
|
|
|
|
|
expect(copy(date).getTime()).toEqual(123);
|
|
|
|
|
expect(copy(date) === date).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
|
2010-03-15 21:36:50 +00:00
|
|
|
it("should copy array", function(){
|
|
|
|
|
var src = [1, {name:"value"}];
|
|
|
|
|
var dst = [{key:"v"}];
|
|
|
|
|
assertSame(dst, copy(src, dst));
|
|
|
|
|
assertEquals([1, {name:"value"}], dst);
|
|
|
|
|
assertEquals({name:"value"}, dst[1]);
|
|
|
|
|
assertNotSame(src[1], dst[1]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should copy empty array', function() {
|
|
|
|
|
var src = [];
|
|
|
|
|
var dst = [{key: "v"}];
|
|
|
|
|
assertEquals([], copy(src, dst));
|
|
|
|
|
assertEquals([], dst);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should copy object", function(){
|
|
|
|
|
var src = {a:{name:"value"}};
|
|
|
|
|
var dst = {b:{key:"v"}};
|
|
|
|
|
assertSame(dst, copy(src, dst));
|
|
|
|
|
assertEquals({a:{name:"value"}}, dst);
|
|
|
|
|
assertEquals(src.a, dst.a);
|
|
|
|
|
assertNotSame(src.a, dst.a);
|
|
|
|
|
});
|
2010-05-07 19:09:14 +00:00
|
|
|
|
|
|
|
|
it("should copy primitives", function(){
|
|
|
|
|
expect(copy(null)).toEqual(null);
|
2010-10-06 01:22:19 +00:00
|
|
|
expect(copy('')).toBe('');
|
|
|
|
|
expect(copy('lala')).toBe('lala');
|
2010-05-07 19:09:14 +00:00
|
|
|
expect(copy(123)).toEqual(123);
|
|
|
|
|
expect(copy([{key:null}])).toEqual([{key:null}]);
|
|
|
|
|
});
|
|
|
|
|
|
2010-03-15 21:36:50 +00:00
|
|
|
});
|
2010-07-19 19:29:24 +00:00
|
|
|
|
|
|
|
|
describe('equals', function(){
|
|
|
|
|
it('should return true if same object', function(){
|
|
|
|
|
var o = {};
|
|
|
|
|
expect(equals(o, o)).toEqual(true);
|
|
|
|
|
expect(equals(1, '1')).toEqual(true);
|
|
|
|
|
expect(equals(1, '2')).toEqual(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should recurse into object', function(){
|
|
|
|
|
expect(equals({}, {})).toEqual(true);
|
|
|
|
|
expect(equals({name:'misko'}, {name:'misko'})).toEqual(true);
|
|
|
|
|
expect(equals({name:'misko', age:1}, {name:'misko'})).toEqual(false);
|
|
|
|
|
expect(equals({name:'misko'}, {name:'misko', age:1})).toEqual(false);
|
|
|
|
|
expect(equals({name:'misko'}, {name:'adam'})).toEqual(false);
|
|
|
|
|
expect(equals(['misko'], ['misko'])).toEqual(true);
|
|
|
|
|
expect(equals(['misko'], ['adam'])).toEqual(false);
|
|
|
|
|
expect(equals(['misko'], ['misko', 'adam'])).toEqual(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should ignore $ member variables', function(){
|
|
|
|
|
expect(equals({name:'misko', $id:1}, {name:'misko', $id:2})).toEqual(true);
|
|
|
|
|
expect(equals({name:'misko'}, {name:'misko', $id:2})).toEqual(true);
|
|
|
|
|
expect(equals({name:'misko', $id:1}, {name:'misko'})).toEqual(true);
|
|
|
|
|
});
|
2010-10-08 23:43:40 +00:00
|
|
|
|
|
|
|
|
it('should ignore functions', function(){
|
|
|
|
|
expect(equals({func: function() {}}, {bar: function() {}})).toEqual(true);
|
|
|
|
|
});
|
2010-07-19 19:29:24 +00:00
|
|
|
});
|
2010-09-27 23:00:05 +00:00
|
|
|
|
|
|
|
|
describe('parseKeyValue', function() {
|
|
|
|
|
it('should parse a string into key-value pairs', function() {
|
|
|
|
|
expect(parseKeyValue('')).toEqual({});
|
|
|
|
|
expect(parseKeyValue('simple=pair')).toEqual({simple: 'pair'});
|
|
|
|
|
expect(parseKeyValue('first=1&second=2')).toEqual({first: '1', second: '2'});
|
|
|
|
|
expect(parseKeyValue('escaped%20key=escaped%20value')).
|
|
|
|
|
toEqual({'escaped key': 'escaped value'});
|
|
|
|
|
expect(parseKeyValue('emptyKey=')).toEqual({emptyKey: ''});
|
|
|
|
|
expect(parseKeyValue('flag1&key=value&flag2')).
|
|
|
|
|
toEqual({flag1: true, key: 'value', flag2: true});
|
|
|
|
|
});
|
2010-10-04 16:00:09 +00:00
|
|
|
});
|
2010-10-16 15:13:53 +00:00
|
|
|
|
|
|
|
|
describe('toKeyValue', function() {
|
|
|
|
|
it('should parse key-value pairs into string', function() {
|
|
|
|
|
expect(toKeyValue({})).toEqual('');
|
|
|
|
|
expect(toKeyValue({simple: 'pair'})).toEqual('simple=pair');
|
|
|
|
|
expect(toKeyValue({first: '1', second: '2'})).toEqual('first=1&second=2');
|
|
|
|
|
expect(toKeyValue({'escaped key': 'escaped value'})).
|
|
|
|
|
toEqual('escaped%20key=escaped%20value');
|
|
|
|
|
expect(toKeyValue({emptyKey: ''})).toEqual('emptyKey=');
|
|
|
|
|
});
|
2010-10-19 04:20:47 +00:00
|
|
|
|
2010-10-16 15:15:08 +00:00
|
|
|
it('should parse true values into flags', function() {
|
|
|
|
|
expect(toKeyValue({flag1: true, key: 'value', flag2: true})).toEqual('flag1&key=value&flag2');
|
|
|
|
|
});
|
2010-10-16 15:13:53 +00:00
|
|
|
});
|
2010-10-20 00:07:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
describe ('rngScript', function() {
|
|
|
|
|
it('should match angular.js', function() {
|
|
|
|
|
expect('angular.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
|
|
|
|
|
expect('foo.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('foo/foo.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('my-angular-app.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('foo/../my-angular-app.js'.match(rngScript)).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should match angular.min.js', function() {
|
|
|
|
|
expect('angular.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
|
|
|
|
|
expect('my-angular-app.min.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('foo/../my-angular-app.min.js'.match(rngScript)).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should match angular-bootstrap.js', function() {
|
|
|
|
|
expect('angular-bootstrap.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular-bootstrap.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular-bootstrap.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
|
|
|
|
|
expect('my-angular-app-bootstrap.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('foo/../my-angular-app-bootstrap.js'.match(rngScript)).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should match angular-0.9.0.js', function() {
|
|
|
|
|
expect('angular-0.9.0.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular-0.9.0.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular-0.9.0.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
|
|
|
|
|
expect('my-angular-app-0.9.0.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('foo/../my-angular-app-0.9.0.js'.match(rngScript)).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should match angular-0.9.0.min.js', function() {
|
|
|
|
|
expect('angular-0.9.0.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular-0.9.0.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular-0.9.0.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
|
|
|
|
|
expect('my-angular-app-0.9.0.min.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('foo/../my-angular-app-0.9.0.min.js'.match(rngScript)).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should match angular-0.9.0-de0a8612.js', function() {
|
|
|
|
|
expect('angular-0.9.0-de0a8612.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular-0.9.0-de0a8612.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular-0.9.0-de0a8612.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
|
|
|
|
|
expect('my-angular-app-0.9.0-de0a8612.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('foo/../my-angular-app-0.9.0-de0a8612.js'.match(rngScript)).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should match angular-0.9.0-de0a8612.min.js', function() {
|
|
|
|
|
expect('angular-0.9.0-de0a8612.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular-0.9.0-de0a8612.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular-0.9.0-de0a8612.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
|
|
|
|
|
expect('my-angular-app-0.9.0-de0a8612.min.js'.match(rngScript)).toBeNull();
|
|
|
|
|
expect('foo/../my-angular-app-0.9.0-de0a8612.min.js'.match(rngScript)).toBeNull();
|
|
|
|
|
});
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
|
|
|
|
|
it('should match angular-scenario.js', function() {
|
|
|
|
|
expect('angular-scenario.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('angular-scenario.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular-scenario.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular-scenario.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should match angular-scenario-0.9.0(.min).js', function() {
|
|
|
|
|
expect('angular-scenario-0.9.0.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('angular-scenario-0.9.0.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular-scenario-0.9.0.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular-scenario-0.9.0.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should match angular-scenario-0.9.0-de0a8612(.min).js', function() {
|
|
|
|
|
expect('angular-scenario-0.9.0-de0a8612.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('angular-scenario-0.9.0-de0a8612.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('../angular-scenario-0.9.0-de0a8612.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
expect('foo/angular-scenario-0.9.0-de0a8612.min.js'.match(rngScript)).not.toBeNull();
|
|
|
|
|
});
|
2010-10-20 00:07:20 +00:00
|
|
|
});
|
2010-10-20 00:08:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('angularJsConfig', function() {
|
|
|
|
|
it('should find angular.js script tag and config', function() {
|
|
|
|
|
var doc = { getElementsByTagName: function(tagName) {
|
|
|
|
|
expect(tagName).toEqual('script');
|
|
|
|
|
return [{nodeName: 'SCRIPT', src: 'random.js'},
|
|
|
|
|
{nodeName: 'SCRIPT', src: 'angular.js'},
|
|
|
|
|
{nodeName: 'SCRIPT', src: 'my-angular-app.js'}];
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(angularJsConfig(doc)).toEqual({base_url: '',
|
|
|
|
|
ie_compat: 'angular-ie-compat.js',
|
|
|
|
|
ie_compat_id: 'ng-ie-compat'});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should extract angular config from the ng: attributes', function() {
|
|
|
|
|
var doc = { getElementsByTagName: function(tagName) {
|
|
|
|
|
expect(lowercase(tagName)).toEqual('script');
|
|
|
|
|
return [{nodeName: 'SCRIPT',
|
|
|
|
|
src: 'angularjs/angular.js',
|
|
|
|
|
attributes: [{name: 'ng:autobind', value:undefined},
|
|
|
|
|
{name: 'ng:css', value: 'css/my_custom_angular.css'},
|
|
|
|
|
{name: 'ng:ie-compat', value: 'myjs/angular-ie-compat.js'},
|
|
|
|
|
{name: 'ng:ie-compat-id', value: 'ngcompat'}] }];
|
|
|
|
|
}};
|
|
|
|
|
|
|
|
|
|
expect(angularJsConfig(doc)).toEqual({base_url: 'angularjs/',
|
|
|
|
|
autobind: true,
|
|
|
|
|
css: 'css/my_custom_angular.css',
|
|
|
|
|
ie_compat: 'myjs/angular-ie-compat.js',
|
|
|
|
|
ie_compat_id: 'ngcompat'});
|
|
|
|
|
});
|
2010-10-20 04:53:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
it("should default to versioned ie-compat file if angular file is versioned", function() {
|
|
|
|
|
var doc = { getElementsByTagName: function(tagName) {
|
|
|
|
|
expect(lowercase(tagName)).toEqual('script');
|
|
|
|
|
return [{nodeName: 'SCRIPT',
|
|
|
|
|
src: 'js/angular-0.9.0.js'}];
|
|
|
|
|
}};
|
|
|
|
|
|
|
|
|
|
expect(angularJsConfig(doc)).toEqual({base_url: 'js/',
|
|
|
|
|
ie_compat: 'js/angular-ie-compat-0.9.0.js',
|
|
|
|
|
ie_compat_id: 'ng-ie-compat'});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("should default to versioned ie-compat file if angular file is versioned and minified", function() {
|
|
|
|
|
var doc = { getElementsByTagName: function(tagName) {
|
|
|
|
|
expect(lowercase(tagName)).toEqual('script');
|
|
|
|
|
return [{nodeName: 'SCRIPT',
|
|
|
|
|
src: 'js/angular-0.9.0-cba23f00.min.js'}];
|
|
|
|
|
}};
|
|
|
|
|
|
|
|
|
|
expect(angularJsConfig(doc)).toEqual({base_url: 'js/',
|
|
|
|
|
ie_compat: 'js/angular-ie-compat-0.9.0-cba23f00.js',
|
|
|
|
|
ie_compat_id: 'ng-ie-compat'});
|
|
|
|
|
});
|
2010-10-20 00:08:00 +00:00
|
|
|
});
|