Skip to content

Commit d38af4e

Browse files
test(state): fix karma test for angular 1.0.8
test(UrlMatcher): fix karma test for angular 1.0.8
1 parent 0c983a0 commit d38af4e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

test/stateSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ describe('state', function () {
518518
}));
519519

520520
it('should invoke the controller', inject(function ($state, $q, $timeout, $rootScope, $compile) {
521-
$compile('<div ui-view/>')($rootScope);
521+
$compile('<div> <div ui-view/> </div>')($rootScope);
522522
$state.transitionTo('resolveTimeout', { foo: "bar" });
523523
$timeout.flush();
524524
$q.flush();

test/urlMatcherFactorySpec.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ describe("UrlMatcher", function () {
236236
$location.url("/foo?param1=bar");
237237
expect(m.exec($location.path(), $location.search())).toEqual( { param1: 'bar' } ); // auto unwrap
238238
$location.url("/foo?param1=bar&param1=baz");
239-
expect(m.exec($location.path(), $location.search())).toEqual( { param1: ['bar', 'baz'] } );
239+
if (angular.isArray($location.search())) // conditional for angular 1.0.8
240+
expect(m.exec($location.path(), $location.search())).toEqual( { param1: ['bar', 'baz'] } );
240241

241242
expect(m.format({ })).toBe("/foo");
242243
expect(m.format({ param1: undefined })).toBe("/foo");
@@ -269,7 +270,8 @@ describe("UrlMatcher", function () {
269270
$location.url("/foo?param1=bar");
270271
expect(m.exec($location.path(), $location.search())).toEqual( { param1: [ 'bar' ] } );
271272
$location.url("/foo?param1=bar&param1=baz");
272-
expect(m.exec($location.path(), $location.search())).toEqual( { param1: ['bar', 'baz'] } );
273+
if (angular.isArray($location.search())) // conditional for angular 1.0.8
274+
expect(m.exec($location.path(), $location.search())).toEqual( { param1: ['bar', 'baz'] } );
273275

274276
expect(m.format({ })).toBe("/foo");
275277
expect(m.format({ param1: undefined })).toBe("/foo");
@@ -290,7 +292,8 @@ describe("UrlMatcher", function () {
290292
expect(m.format({ "param1[]": [ 'bar' ] })).toBe("/foo?param1[]=bar");
291293

292294
$location.url("/foo?param1[]=bar&param1[]=baz");
293-
expect(m.exec($location.path(), $location.search())).toEqual( { "param1[]": ['bar', 'baz'] } );
295+
if (angular.isArray($location.search())) // conditional for angular 1.0.8
296+
expect(m.exec($location.path(), $location.search())).toEqual( { "param1[]": ['bar', 'baz'] } );
294297
expect(m.format({ "param1[]": ['bar', 'baz'] })).toBe("/foo?param1[]=bar&param1[]=baz");
295298
}));
296299

@@ -305,7 +308,8 @@ describe("UrlMatcher", function () {
305308
expect(m.format({ param1: [ 'bar' ] })).toBe("/foo?param1=bar");
306309

307310
$location.url("/foo?param1=bar&param1=baz");
308-
expect(m.exec($location.path(), $location.search())).toEqual( { param1: 'bar,baz' } ); // coerced to string
311+
if (angular.isArray($location.search())) // conditional for angular 1.0.8
312+
expect(m.exec($location.path(), $location.search())).toEqual( { param1: 'bar,baz' } ); // coerced to string
309313
expect(m.format({ param1: ['bar', 'baz'] })).toBe("/foo?param1=bar%2Cbaz"); // coerced to string
310314
}));
311315
});
@@ -501,7 +505,8 @@ describe("urlMatcherFactory", function () {
501505
expect(m.format({ fooid: 5, bar: 1 })).toEqual("/foo/5?bar=1");
502506

503507
$location.url("/foo/5?bar=1&bar=2&bar=3");
504-
expect(m.exec($location.path(), $location.search())).toEqual( { fooid: 5, bar: [ 1, 2, 3 ] } );
508+
if (angular.isArray($location.search())) // conditional for angular 1.0.8
509+
expect(m.exec($location.path(), $location.search())).toEqual( { fooid: 5, bar: [ 1, 2, 3 ] } );
505510
expect(m.format({ fooid: 5, bar: [ 1, 2, 3 ] })).toEqual("/foo/5?bar=1&bar=2&bar=3");
506511

507512
m.format()

0 commit comments

Comments
 (0)