1
+ /* global describe, beforeEach, inject, afterEach, it, expect, spyOn */
2
+ /* jshint unused: false */
1
3
describe ( 'Restangular' , function ( ) {
2
4
// API
3
- var Restangular , $httpBackend ;
4
- var accountsModel , restangularAccounts , restangularAccount0 , restangularAccount1 ;
5
- var accountsHalModel ;
6
- var messages , newAccount , nextAccountId ;
5
+ var Restangular , $httpBackend ,
6
+ accountsModel , restangularAccounts , restangularAccount0 , restangularAccount1 ,
7
+ infoModel , accountsDoSomethingModel , customers , publications , newCustomer ,
8
+ accountsHalModel ,
9
+ messages , newAccount , nextAccountId ;
7
10
8
11
// Load required modules
9
12
beforeEach ( angular . mock . module ( 'restangular' ) ) ;
@@ -873,7 +876,7 @@ describe('Restangular', function() {
873
876
} ) . then ( function ( accountFromServer2 ) {
874
877
expect ( accountFromServer2 . route ) . toBe ( account1 . route ) ;
875
878
} ) ;
876
- $httpBackend . flush ( )
879
+ $httpBackend . flush ( ) ;
877
880
} ) ;
878
881
879
882
it ( 'Should make RequestLess connections with one' , function ( ) {
@@ -1018,7 +1021,7 @@ describe('Restangular', function() {
1018
1021
} ) ;
1019
1022
1020
1023
it ( 'should allow for a custom method to be placed at the model level when several models are requested' , function ( ) {
1021
- var accountPromise ;
1024
+ var accountsPromise ;
1022
1025
1023
1026
Restangular . addElementTransformer ( 'accounts' , false , function ( model ) {
1024
1027
model . prettifyAmount = function ( ) { } ;
@@ -1028,16 +1031,16 @@ describe('Restangular', function() {
1028
1031
accountsPromise = Restangular . all ( 'accounts' , 1 ) . getList ( ) ;
1029
1032
1030
1033
accountsPromise . then ( function ( accounts ) {
1031
- accounts . forEach ( function ( account , index ) {
1034
+ accounts . forEach ( function ( account ) {
1032
1035
expect ( typeof account . prettifyAmount ) . toEqual ( 'function' ) ;
1033
1036
} ) ;
1034
1037
} ) ;
1035
1038
1036
1039
$httpBackend . flush ( ) ;
1037
1040
} ) ;
1038
1041
1039
- it ( " should allow for a custom method to be placed at the collection level using a regexp matching the route" , function ( ) {
1040
- var accountPromise ;
1042
+ it ( ' should allow for a custom method to be placed at the collection level using a regexp matching the route' , function ( ) {
1043
+ var accountsPromise ;
1041
1044
1042
1045
Restangular . addElementTransformer ( / ^ a c c o u n t s / , false , function ( model ) {
1043
1046
model . prettifyAmount = function ( ) { } ;
@@ -1047,15 +1050,15 @@ describe('Restangular', function() {
1047
1050
accountsPromise = Restangular . all ( 'accounts/search/byOwner' , 1 ) . getList ( ) ;
1048
1051
1049
1052
accountsPromise . then ( function ( accounts ) {
1050
- accounts . forEach ( function ( account , index ) {
1051
- expect ( typeof account . prettifyAmount ) . toEqual ( " function" ) ;
1053
+ accounts . forEach ( function ( account ) {
1054
+ expect ( typeof account . prettifyAmount ) . toEqual ( ' function' ) ;
1052
1055
} ) ;
1053
1056
} ) ;
1054
1057
1055
1058
$httpBackend . flush ( ) ;
1056
1059
} ) ;
1057
1060
1058
- it ( " should allow for a custom method to be placed at the model level using regexp route when one model is requested" , function ( ) {
1061
+ it ( ' should allow for a custom method to be placed at the model level using regexp route when one model is requested' , function ( ) {
1059
1062
var accountPromise ;
1060
1063
1061
1064
Restangular . addElementTransformer ( / ^ a c c o u n t s / , false , function ( model ) {
@@ -1066,14 +1069,14 @@ describe('Restangular', function() {
1066
1069
accountPromise = Restangular . one ( 'accounts' , 1 ) . get ( ) ;
1067
1070
1068
1071
accountPromise . then ( function ( account ) {
1069
- expect ( typeof account . prettifyAmount ) . toEqual ( " function" ) ;
1072
+ expect ( typeof account . prettifyAmount ) . toEqual ( ' function' ) ;
1070
1073
} ) ;
1071
1074
1072
1075
$httpBackend . flush ( ) ;
1073
1076
} ) ;
1074
1077
1075
- it ( " should allow for a custom method to be placed at the model level using regexp when several models are requested" , function ( ) {
1076
- var accountPromise ;
1078
+ it ( ' should allow for a custom method to be placed at the model level using regexp when several models are requested' , function ( ) {
1079
+ var accountsPromise ;
1077
1080
1078
1081
Restangular . addElementTransformer ( / ^ a c c o u n t s / , false , function ( model ) {
1079
1082
model . prettifyAmount = function ( ) { } ;
@@ -1083,8 +1086,8 @@ describe('Restangular', function() {
1083
1086
accountsPromise = Restangular . all ( 'accounts' , 1 ) . getList ( ) ;
1084
1087
1085
1088
accountsPromise . then ( function ( accounts ) {
1086
- accounts . forEach ( function ( account , index ) {
1087
- expect ( typeof account . prettifyAmount ) . toEqual ( " function" ) ;
1089
+ accounts . forEach ( function ( account ) {
1090
+ expect ( typeof account . prettifyAmount ) . toEqual ( ' function' ) ;
1088
1091
} ) ;
1089
1092
} ) ;
1090
1093
@@ -1244,7 +1247,7 @@ describe('Restangular', function() {
1244
1247
} ) ;
1245
1248
1246
1249
it ( 'getRestangularUrl() returns still the url without id after GET' , function ( ) {
1247
- record = Restangular . one ( 'info' , 0 , true ) ;
1250
+ var record = Restangular . one ( 'info' , 0 , true ) ;
1248
1251
record . get ( ) . then ( function ( data ) {
1249
1252
expect ( data . getRestangularUrl ( ) ) . toEqual ( '/info' ) ;
1250
1253
} ) ;
0 commit comments