'use strict';

const stripe = require('../../testUtils').getSpyableStripe();
const expect = require('chai').expect;

describe('SubscriptionItems Resource', () => {
  describe('retrieve', () => {
    it('Sends the correct request', () => {
      stripe.subscriptionItems.retrieve('test_sub_item');
      expect(stripe.LAST_REQUEST).to.deep.equal({
        method: 'GET',
        url: '/v1/subscription_items/test_sub_item',
        headers: {},
        data: {},
      });
    });
  });

  describe('del', () => {
    it('Sends the correct request', () => {
      stripe.subscriptionItems.del('test_sub_item');
      expect(stripe.LAST_REQUEST).to.deep.equal({
        method: 'DELETE',
        url: '/v1/subscription_items/test_sub_item',
        headers: {},
        data: {},
      });
    });
  });

  describe('update', () => {
    it('Sends the correct request', () => {
      stripe.subscriptionItems.update('test_sub_item', {
        plan: 'gold',
      });
      expect(stripe.LAST_REQUEST).to.deep.equal({
        method: 'POST',
        url: '/v1/subscription_items/test_sub_item',
        headers: {},
        data: {
          plan: 'gold',
        },
      });
    });
  });

  describe('create', () => {
    it('Sends the correct request', () => {
      stripe.subscriptionItems.create({
        subscription: 'test_sub',
        plan: 'gold',
      });

      expect(stripe.LAST_REQUEST).to.deep.equal({
        method: 'POST',
        url: '/v1/subscription_items',
        headers: {},
        data: {
          subscription: 'test_sub',
          plan: 'gold',
        },
      });
    });
  });

  describe('list', () => {
    it('Sends the correct request', () => {
      stripe.subscriptionItems.list({
        limit: 3,
        subscription: 'test_sub',
      });
      expect(stripe.LAST_REQUEST).to.deep.equal({
        method: 'GET',
        url: '/v1/subscription_items',
        headers: {},
        data: {
          limit: 3,
          subscription: 'test_sub',
        },
      });
    });
  });
});

@@ -2018,13 +2018,466 @@
 );%0A  %7D);
+%0A%0A  describe('createUsageRecord', () =%3E %7B%0A    it('Sends the correct request', () =%3E %7B%0A      const data = %7B%0A        quantity: 123,%0A        timestamp: 123321,%0A        action: 'increment',%0A      %7D;%0A      stripe.subscriptionItems.createUsageRecord('si_123', data);%0A      expect(stripe.LAST_REQUEST).to.deep.equal(%7B%0A        method: 'POST',%0A        url: '/v1/subscription_items/si_123/usage_records',%0A        headers: %7B%7D,%0A        data,%0A      %7D);%0A    %7D);%0A  %7D);
 %0A%7D);%0A

Add tests