1- import { createLocalVue , shallow } from '@vue/test-utils' ;
1+ import { createLocalVue , shallowMount } from '@vue/test-utils' ;
22import PayPalCheckout from '@/components/PayPalCheckout.vue' ;
33
44const credentials = {
@@ -54,52 +54,56 @@ jest.mock('paypal-checkout', () => ({
5454} ) ) ;
5555
5656describe ( 'Methods within PayPalCheckout.vue' , ( ) => {
57- const localVue = createLocalVue ( ) ;
58- const checkout = shallow ( PayPalCheckout , {
59- localVue,
60- attachToDocument : true ,
61- propsData : getProps ( ) ,
57+ let checkout ;
58+
59+ beforeEach ( ( ) => {
60+ const localVue = createLocalVue ( ) ;
61+ checkout = shallowMount ( PayPalCheckout , {
62+ localVue,
63+ attachToDocument : true ,
64+ propsData : getProps ( ) ,
65+ } ) ;
6266 } ) ;
6367
6468 describe ( 'Environment' , ( ) => {
65- it ( 'env prop is true' , ( ) => {
69+ test ( 'env prop is true' , ( ) => {
6670 expect ( checkout . props ( ) . env ) . toEqual ( 'sandbox' ) ;
6771 } ) ;
6872 } ) ;
6973
7074 describe ( 'vue.payment()' , ( ) => {
71- it ( 'has payment()' , ( ) => {
75+ test ( 'has payment()' , ( ) => {
7276 expect ( checkout . vm ) . toEqual ( expect . objectContaining ( {
7377 payment : expect . any ( Function ) ,
7478 } ) ) ;
7579 } ) ;
7680
77- it ( 'returns a payment object' , ( ) => (
81+ test ( 'returns a payment object' , ( ) => (
7882 checkout . vm . payment ( ) . then ( ( p ) => {
7983 expect ( p ) . toBeInstanceOf ( Object ) ;
8084 } )
8185 ) ) ;
8286
83- it ( 'payment object has experience object' , ( ) => {
87+ test ( 'payment object has experience object' , ( ) => {
8488 checkout . vm . payment ( ) . then ( ( p ) => {
8589 expect ( p . experience ) . toEqual ( checkout . vm . experience ) ;
8690 } ) ;
8791 } ) ;
8892
89- it ( 'payment object has transactions array' , ( ) => (
93+ test ( 'payment object has transactions array' , ( ) => (
9094 checkout . vm . payment ( ) . then ( ( p ) => {
9195 expect ( p . payment ) . toEqual ( expect . objectContaining ( {
9296 transactions : expect . any ( Array ) ,
9397 } ) ) ;
9498 } ) ) ) ;
9599
96- it ( 'payment object has one single transaction' , ( ) => (
100+ test ( 'payment object has one single transaction' , ( ) => (
97101 checkout . vm . payment ( ) . then ( ( p ) => {
98102 expect ( p . payment . transactions . length ) . toBe ( 1 ) ;
99103 } )
100104 ) ) ;
101105
102- it ( 'transaction has the right amount' , ( ) => (
106+ test ( 'transaction has the right amount' , ( ) => (
103107 checkout . vm . payment ( ) . then ( ( p ) => {
104108 const transaction = p . payment . transactions [ 0 ] ;
105109 expect ( transaction . amount ) . toEqual ( expect . objectContaining ( {
@@ -109,7 +113,7 @@ describe('Methods within PayPalCheckout.vue', () => {
109113 } )
110114 ) ) ;
111115
112- it ( 'transaction has the right currency' , ( ) => (
116+ test ( 'transaction has the right currency' , ( ) => (
113117 checkout . vm . payment ( ) . then ( ( p ) => {
114118 const transaction = p . payment . transactions [ 0 ] ;
115119 expect ( transaction . amount ) . toEqual ( expect . objectContaining ( {
@@ -119,7 +123,7 @@ describe('Methods within PayPalCheckout.vue', () => {
119123 } )
120124 ) ) ;
121125
122- it ( 'transaction has the right invoice number' , ( ) => (
126+ test ( 'transaction has the right invoice number' , ( ) => (
123127 checkout . vm . payment ( ) . then ( ( p ) => {
124128 const transaction = p . payment . transactions [ 0 ] ;
125129 expect ( transaction ) . toEqual ( expect . objectContaining ( {
@@ -129,7 +133,7 @@ describe('Methods within PayPalCheckout.vue', () => {
129133 } )
130134 ) ) ;
131135
132- it ( 'transaction has a item_list' , ( ) => (
136+ test ( 'transaction has a item_list' , ( ) => (
133137 checkout . vm . payment ( ) . then ( ( p ) => {
134138 const transaction = p . payment . transactions [ 0 ] ;
135139 expect ( transaction ) . toEqual ( expect . objectContaining ( {
@@ -138,7 +142,7 @@ describe('Methods within PayPalCheckout.vue', () => {
138142 } )
139143 ) ) ;
140144
141- it ( 'transaction has items array' , ( ) => (
145+ test ( 'transaction has items array' , ( ) => (
142146 checkout . vm . payment ( ) . then ( ( p ) => {
143147 const itemList = p . payment . transactions [ 0 ] . item_list ;
144148 expect ( itemList ) . toEqual ( expect . objectContaining ( {
@@ -150,16 +154,16 @@ describe('Methods within PayPalCheckout.vue', () => {
150154 } ) ;
151155
152156 describe ( 'action methods' , ( ) => {
153- it ( 'has onAuthorize() and onCancel()' , ( ) => {
157+ test ( 'has onAuthorize() and onCancel()' , ( ) => {
154158 expect ( checkout . vm ) . toEqual ( expect . objectContaining ( {
155159 onAuthorize : expect . any ( Function ) ,
156160 onCancel : expect . any ( Function ) ,
157161 } ) ) ;
158162 } ) ;
159163
160- it ( 'onAuthorize() returns true and not a promise if commit is false' , ( ) => {
161- const component = shallow ( PayPalCheckout , {
162- localVue,
164+ test ( 'onAuthorize() returns true and not a promise if commit is false' , ( ) => {
165+ const component = shallowMount ( PayPalCheckout , {
166+ localVue : createLocalVue ( ) ,
163167 attachToDocument : true ,
164168 propsData : { ...getProps ( ) , commit : false } ,
165169 } ) ;
0 commit comments