/* global Stripe */

import Ember from 'ember';
import { moduleFor, test } from 'ember-qunit';
import env from 'dummy/config/environment';

moduleFor('service:stripe', '[integration] - StripeService', {
  // Specify the other units that are required for this test.
  // needs: ['service:foo']
});

var cc = {
  number: 4242424242424242,
  exp_year: 2018,
  exp_month: 10,
  cvc: 123,
  address_zip: 12345
};

var bankAccount= {
  country: 'US',
  routingNumber: '111000025',
  accountNumber: '000123456789',
};

Stripe.setPublishableKey(env.stripe.publishableKey);

test('card.createToken sets the token and returns a promise', function(assert) {
  var service = this.subject();

  Ember.run(function(){
    service.card.createToken(cc)
      .then(function(res) {
        assert.ok(res.id, 'correct token set');
      })
      .catch(function(error) {
        throw error;
      });
    });
});

test('bankAccount.createToken sets the token and returns a promise', function(assert) {
  var service = this.subject();

  Ember.run(function(){
    service.bankAccount.createToken(bankAccount)
      .then(function(res) {
        assert.ok(res.id, 'correct token set');
      })
      .catch(function(error) {
        throw error;
      });
    });
});


@@ -730,26 +730,24 @@
 ken(cc)%0A    
-  
 .then(functi
@@ -748,34 +748,32 @@
 function(res) %7B%0A
-  
       assert.ok(
@@ -806,87 +806,16 @@
 ');%0A
-      %7D)%0A      .catch(function(error) %7B%0A        throw error;%0A      %7D);%0A
     %7D);%0A
 %7D);%0A
@@ -806,24 +806,30 @@
 ');%0A    %7D);%0A
+  %7D);%0A
 %7D);%0A%0Atest('b
@@ -1019,18 +1019,16 @@
 nt)%0A    
-  
 .then(fu
@@ -1037,26 +1037,24 @@
 tion(res) %7B%0A
-  
       assert
@@ -1095,77 +1095,12 @@
     
-  %7D)%0A      .catch(function(error) %7B%0A        throw error;%0A      %7D);%0A  
+%7D);%0A
   %7D)

test style