@@ -1010,6 +1010,176 @@ define(['angular', 'given', 'util'], function(angular, given, util) {
1010
1010
} ) ;
1011
1011
} ) ;
1012
1012
1013
+ describe ( '$resource generated with includeCommonModules:false' , function ( ) {
1014
+ var $injector ;
1015
+ before ( function ( ) {
1016
+ return given . servicesForLoopBackApp (
1017
+ {
1018
+ models : {
1019
+ Product : {
1020
+ properties : {
1021
+ name : 'string' ,
1022
+ price : { type : 'number' } ,
1023
+ } ,
1024
+ } ,
1025
+ } ,
1026
+ includeCommonModules : false ,
1027
+ } )
1028
+ . then ( function ( createInjector ) {
1029
+ $injector = createInjector ( ) ;
1030
+ } ) ;
1031
+ } ) ;
1032
+
1033
+ it ( 'does not have "LoopBackAuth module"' , function ( ) {
1034
+ var Product = $injector . get ( 'Product' ) ;
1035
+ var methodNames = Object . keys ( Product ) ;
1036
+ expect ( methodNames ) . to . include . members ( [ 'schema' ] ) ;
1037
+ var schema = Product . schema ;
1038
+ expect ( schema ) . to . have . property ( 'name' , 'Product' ) ;
1039
+ expect ( schema ) . to . have . property ( 'properties' ) ;
1040
+ console . log ( 'schema properties' , schema . properties ) ;
1041
+ expect ( schema . properties ) . to . eql ( {
1042
+ // "name: 'string'" was converted to full schema object
1043
+ name : { type : 'String' } ,
1044
+ // Type "number" was normalized to "Number"
1045
+ price : { type : 'Number' } ,
1046
+ // auto-injected id property
1047
+ id : { id : 1 , generated : true , type : 'Number' } ,
1048
+ } ) ;
1049
+ } ) ;
1050
+
1051
+ it ( 'does not have "LoopBackAuth module"' , function ( ) {
1052
+ var Product = $injector . get ( 'Product' ) ;
1053
+ var methodNames = Object . keys ( Product ) ;
1054
+ expect ( methodNames ) . to . include . members ( [ 'schema' ] ) ;
1055
+ var schema = Product . schema ;
1056
+ expect ( schema ) . to . have . property ( 'name' , 'Product' ) ;
1057
+ expect ( schema ) . to . have . property ( 'properties' ) ;
1058
+ console . log ( 'schema properties' , schema . properties ) ;
1059
+ expect ( schema . properties ) . to . eql ( {
1060
+ // "name: 'string'" was converted to full schema object
1061
+ name : { type : 'String' } ,
1062
+ // Type "number" was normalized to "Number"
1063
+ price : { type : 'Number' } ,
1064
+ // auto-injected id property
1065
+ id : { id : 1 , generated : true , type : 'Number' } ,
1066
+ } ) ;
1067
+ } ) ;
1068
+
1069
+
1070
+ it ( 'does not have "LoopBackResource provider"' , function ( ) {
1071
+ var Product = $injector . get ( 'Product' ) ;
1072
+ var methodNames = Object . keys ( Product ) ;
1073
+ expect ( methodNames ) . to . include . members ( [ 'schema' ] ) ;
1074
+ var schema = Product . schema ;
1075
+ expect ( schema ) . to . have . property ( 'name' , 'Product' ) ;
1076
+ expect ( schema ) . to . have . property ( 'properties' ) ;
1077
+ console . log ( 'schema properties' , schema . properties ) ;
1078
+ expect ( schema . properties ) . to . eql ( {
1079
+ // "name: 'string'" was converted to full schema object
1080
+ name : { type : 'String' } ,
1081
+ // Type "number" was normalized to "Number"
1082
+ price : { type : 'Number' } ,
1083
+ // auto-injected id property
1084
+ id : { id : 1 , generated : true , type : 'Number' } ,
1085
+ } ) ;
1086
+ } ) ;
1087
+
1088
+ it ( 'does not have "LoopBackAuthRequestInterceptor module"' , function ( ) {
1089
+ var Product = $injector . get ( 'Product' ) ;
1090
+ var methodNames = Object . keys ( Product ) ;
1091
+ expect ( methodNames ) . to . include . members ( [ 'schema' ] ) ;
1092
+ var schema = Product . schema ;
1093
+ expect ( schema ) . to . have . property ( 'name' , 'Product' ) ;
1094
+ expect ( schema ) . to . have . property ( 'properties' ) ;
1095
+ console . log ( 'schema properties' , schema . properties ) ;
1096
+ expect ( schema . properties ) . to . eql ( {
1097
+ // "name: 'string'" was converted to full schema object
1098
+ name : { type : 'String' } ,
1099
+ // Type "number" was normalized to "Number"
1100
+ price : { type : 'Number' } ,
1101
+ // auto-injected id property
1102
+ id : { id : 1 , generated : true , type : 'Number' } ,
1103
+ } ) ;
1104
+ } ) ;
1105
+ } ) ;
1106
+
1107
+ describe ( '$resource generated with namespaceModels:true' , function ( ) {
1108
+ var $injector ;
1109
+ before ( function ( ) {
1110
+ return given . servicesForLoopBackApp (
1111
+ {
1112
+ models : {
1113
+ Product : {
1114
+ properties : {
1115
+ name : 'string' ,
1116
+ price : { type : 'number' } ,
1117
+ } ,
1118
+ } ,
1119
+ } ,
1120
+ namespaceModels : true ,
1121
+ } )
1122
+ . then ( function ( createInjector ) {
1123
+ $injector = createInjector ( ) ;
1124
+ } ) ;
1125
+ } ) ;
1126
+
1127
+ it ( 'defines the "Product" model as "lbServices.Product"' , function ( ) {
1128
+ var Product = $injector . get ( 'Product' ) ;
1129
+ var methodNames = Object . keys ( Product ) ;
1130
+ expect ( methodNames ) . to . include . members ( [ 'schema' ] ) ;
1131
+ var schema = Product . schema ;
1132
+ expect ( schema ) . to . have . property ( 'name' , 'Product' ) ;
1133
+ expect ( schema ) . to . have . property ( 'properties' ) ;
1134
+ console . log ( 'schema properties' , schema . properties ) ;
1135
+ expect ( schema . properties ) . to . eql ( {
1136
+ // "name: 'string'" was converted to full schema object
1137
+ name : { type : 'String' } ,
1138
+ // Type "number" was normalized to "Number"
1139
+ price : { type : 'Number' } ,
1140
+ // auto-injected id property
1141
+ id : { id : 1 , generated : true , type : 'Number' } ,
1142
+ } ) ;
1143
+ } ) ;
1144
+ } ) ;
1145
+
1146
+ describe ( '$resource generated with namespaceModels:true and ' +
1147
+ ' namespaceDelimiter:_' , function ( ) {
1148
+ var $injector ;
1149
+ before ( function ( ) {
1150
+ return given . servicesForLoopBackApp (
1151
+ {
1152
+ models : {
1153
+ Product : {
1154
+ properties : {
1155
+ name : 'string' ,
1156
+ price : { type : 'number' } ,
1157
+ } ,
1158
+ } ,
1159
+ } ,
1160
+ namespaceModels : true ,
1161
+ namespaceDelimiter : _ ,
1162
+ } )
1163
+ . then ( function ( createInjector ) {
1164
+ $injector = createInjector ( ) ;
1165
+ } ) ;
1166
+ } ) ;
1167
+
1168
+ it ( 'defines the "Product" model as "lbServices_Product"' , function ( ) {
1169
+ var Product = $injector . get ( 'lbServices_Product' ) ;
1170
+
1171
+ console . log ( 'schema properties' , schema . properties ) ;
1172
+ expect ( schema . properties ) . to . eql ( {
1173
+ // "name: 'string'" was converted to full schema object
1174
+ name : { type : 'String' } ,
1175
+ // Type "number" was normalized to "Number"
1176
+ price : { type : 'Number' } ,
1177
+ // auto-injected id property
1178
+ id : { id : 1 , generated : true , type : 'Number' } ,
1179
+ } ) ;
1180
+ } ) ;
1181
+ } ) ;
1182
+
1013
1183
describe ( 'for models with belongsTo relation' , function ( ) {
1014
1184
var $injector , Town , Country , testData ;
1015
1185
before ( function ( ) {
0 commit comments