File size: 2,288 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import {
	CONNECTED_APPLICATION_DELETE,
	CONNECTED_APPLICATION_DELETE_SUCCESS,
	CONNECTED_APPLICATIONS_RECEIVE,
	CONNECTED_APPLICATIONS_REQUEST,
} from 'calypso/state/action-types';
import {
	deleteConnectedApplication,
	deleteConnectedApplicationSuccess,
	receiveConnectedApplications,
	requestConnectedApplications,
} from '../actions';

describe( 'actions', () => {
	describe( 'requestConnectedApplications()', () => {
		test( 'should return a connected applications request action object', () => {
			const action = requestConnectedApplications();

			expect( action ).toEqual( {
				type: CONNECTED_APPLICATIONS_REQUEST,
			} );
		} );
	} );

	describe( 'receiveConnectedApplications()', () => {
		test( 'should return a connected applications receive action object', () => {
			const apps = [
				{
					ID: '12345678',
					URL: 'http://wordpress.com',
					authorized: '2018-01-01T00:00:00+00:00',
					description: 'Example description of the application here',
					icon: 'https://wordpress.com/calypso/images/wordpress/logo-stars.svg',
					permissions: [
						{
							name: 'follow',
							description: 'Follow and unfollow blogs.',
						},
						{
							name: 'posts',
							description: 'View and manage posts including reblogs and likes.',
						},
					],
					scope: 'global',
					site: {
						site_ID: '87654321',
						site_URL: 'http://wordpress.com',
						site_name: 'WordPress',
					},
					title: 'WordPress',
				},
			];
			const action = receiveConnectedApplications( apps );

			expect( action ).toEqual( {
				type: CONNECTED_APPLICATIONS_RECEIVE,
				apps,
			} );
		} );
	} );

	describe( 'deleteConnectedApplication()', () => {
		test( 'should return a connected application delete action object', () => {
			const appId = '12345678';
			const action = deleteConnectedApplication( appId );

			expect( action ).toEqual( {
				type: CONNECTED_APPLICATION_DELETE,
				appId,
			} );
		} );
	} );

	describe( 'deleteConnectedApplicationSuccess()', () => {
		test( 'should return a connected application delete success action object', () => {
			const appId = '12345678';
			const action = deleteConnectedApplicationSuccess( appId );

			expect( action ).toEqual( {
				type: CONNECTED_APPLICATION_DELETE_SUCCESS,
				appId,
			} );
		} );
	} );
} );