@@ -11,35 +11,89 @@ describe('Plans Resource', function() {
1111 method : 'GET' ,
1212 url : '/v1/plans/planId1' ,
1313 headers : { } ,
14- data : { } ,
14+ data : { }
1515 } ) ;
1616 } ) ;
1717 } ) ;
1818
1919 describe ( 'create' , function ( ) {
2020 it ( 'Sends the correct request' , function ( ) {
2121 stripe . plans . create ( {
22- amount : 200 , currency : 'usd' ,
22+ amount : 200 ,
23+ currency : 'usd'
2324 } ) ;
2425 expect ( stripe . LAST_REQUEST ) . to . deep . equal ( {
2526 method : 'POST' ,
2627 url : '/v1/plans' ,
2728 headers : { } ,
28- data : { amount : 200 , currency : 'usd' } ,
29+ data : { amount : 200 , currency : 'usd' }
30+ } ) ;
31+ } ) ;
32+
33+ it ( 'Sends the correct request for metered' , function ( ) {
34+ stripe . plans . create ( {
35+ amount : 200 ,
36+ currency : 'usd' ,
37+ usage_type : 'metered'
38+ } ) ;
39+ expect ( stripe . LAST_REQUEST ) . to . deep . equal ( {
40+ method : 'POST' ,
41+ url : '/v1/plans' ,
42+ headers : { } ,
43+ data : { amount : 200 , currency : 'usd' , usage_type : 'metered' }
44+ } ) ;
45+ } ) ;
46+
47+ it ( 'Sends the correct request for tiered plans' , function ( ) {
48+ stripe . plans . create ( {
49+ currency : 'usd' ,
50+ billing_scheme : 'tiered' ,
51+ tiers : [ { up_to : 123 , amount : 100 } , { up_to : 'inf' , amount : 200 } ] ,
52+ tiers_mode : 'volume'
53+ } ) ;
54+ expect ( stripe . LAST_REQUEST ) . to . deep . equal ( {
55+ method : 'POST' ,
56+ url : '/v1/plans' ,
57+ headers : { } ,
58+ data : {
59+ currency : 'usd' ,
60+ billing_scheme : 'tiered' ,
61+ tiers : [ { up_to : 123 , amount : 100 } , { up_to : 'inf' , amount : 200 } ] ,
62+ tiers_mode : 'volume'
63+ }
64+ } ) ;
65+ } ) ;
66+
67+ it ( 'Sends the correct request for transform usage plans' , function ( ) {
68+ stripe . plans . create ( {
69+ amount : 200 ,
70+ currency : 'usd' ,
71+ transform_usage : { divide_by : 123 , round : 'up' }
72+ } ) ;
73+ expect ( stripe . LAST_REQUEST ) . to . deep . equal ( {
74+ method : 'POST' ,
75+ url : '/v1/plans' ,
76+ headers : { } ,
77+ data : {
78+ amount : 200 ,
79+ currency : 'usd' ,
80+ transform_usage : { divide_by : 123 , round : 'up' }
81+ }
2982 } ) ;
3083 } ) ;
3184 } ) ;
3285
3386 describe ( 'update' , function ( ) {
3487 it ( 'Sends the correct request' , function ( ) {
3588 stripe . plans . update ( 'planId3' , {
36- amount : 1900 , currency : 'usd' ,
89+ amount : 1900 ,
90+ currency : 'usd'
3791 } ) ;
3892 expect ( stripe . LAST_REQUEST ) . to . deep . equal ( {
3993 method : 'POST' ,
4094 url : '/v1/plans/planId3' ,
4195 headers : { } ,
42- data : { amount : 1900 , currency : 'usd' } ,
96+ data : { amount : 1900 , currency : 'usd' }
4397 } ) ;
4498 } ) ;
4599 } ) ;
@@ -51,7 +105,7 @@ describe('Plans Resource', function() {
51105 method : 'DELETE' ,
52106 url : '/v1/plans/planId4' ,
53107 headers : { } ,
54- data : { } ,
108+ data : { }
55109 } ) ;
56110 } ) ;
57111 } ) ;
@@ -63,7 +117,7 @@ describe('Plans Resource', function() {
63117 method : 'GET' ,
64118 url : '/v1/plans' ,
65119 headers : { } ,
66- data : { } ,
120+ data : { }
67121 } ) ;
68122 } ) ;
69123 } ) ;
0 commit comments