File size: 823 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { PURCHASE_CANCELLATION_OFFER_RECEIVE } from 'calypso/state/action-types';
import { offers } from '../reducer';
import type { AnyAction } from 'redux';

describe( 'reducer', () => {
	describe( '#cancellationOffers()', () => {
		describe( 'offers', () => {
			test( 'Should transform the API response to match typed object definition', () => {
				const state = offers( undefined, {
					type: PURCHASE_CANCELLATION_OFFER_RECEIVE,
					offers: [
						{
							currency_code: 'USD',
							discount_percentage: 20,
							discounted_periods: 1,
							formatted_price: '$99.95',
						},
					],
				} as AnyAction );

				expect( state ).toEqual( [
					{
						currencyCode: 'USD',
						discountPercentage: 20,
						discountedPeriods: 1,
						formattedPrice: '$99.95',
					},
				] );
			} );
		} );
	} );
} );