File size: 3,001 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { tourBranching } from '../tour-branching';

describe( 'Guided Tours Branching', () => {
	test( 'tourBranching returns a branch tree for a tour JSX tree', () => {
		// We are testing just a tree of elements created by React.createElement. The actual
		// component types don't matter (never rendered) and can be null.
		const Fragment = 'Fragment';
		const Tour = 'Tour';
		const Step = 'Step';
		const ButtonRow = 'ButtonRow';
		const SiteLink = 'SiteLink';

		// These components have `step` props and are checked for `displayName` and `name`
		const Continue = () => null;
		const Next = () => null;

		const tourTree = (
			<Tour name="checklistPublishPost" version="20171205">
				<Step name="init">
					{ ( { translate } ) => (
						<Fragment>
							<p>{ translate( 'It’s time to get your blog rolling with your first post.' ) }</p>
							<ButtonRow>
								<Next step="categories-tags">{ translate( 'All done, continue' ) }</Next>
								<SiteLink>{ translate( 'Return to the checklist' ) } </SiteLink>
								<Continue step="categories-tags" hidden />
							</ButtonRow>
						</Fragment>
					) }
				</Step>

				<Step name="categories-tags">
					{ ( { translate } ) => (
						<Fragment>
							<p>{ translate( 'Categories and Tags' ) }</p>
							<Next step="featured-images">{ translate( 'All done, continue' ) }</Next>
						</Fragment>
					) }
				</Step>

				<Step name="featured-images">
					{ ( { translate } ) => (
						<Fragment>
							<Continue step="choose-image">
								<p>{ translate( 'Press anywhere on this image so we can change it.' ) }</p>
							</Continue>
						</Fragment>
					) }
				</Step>
				<Step name="choose-image">
					{ ( { translate } ) => (
						<Fragment>
							<p>{ translate( 'Either pick an image below or add a new one.' ) }</p>
							<Next step="click-set-featured-image">{ translate( 'All done, continue' ) }</Next>
						</Fragment>
					) }
				</Step>
				<Step name="click-set-featured-image">
					{ ( { translate } ) => (
						<Fragment>
							<Continue step="click-update">{ translate( 'We’re all set' ) }</Continue>
						</Fragment>
					) }
				</Step>
				<Step name="click-update">
					{ ( { translate } ) => (
						<Fragment>
							<Continue step="finish">{ translate( 'Almost done' ) }</Continue>
						</Fragment>
					) }
				</Step>
				<Step name="finish">
					{ ( { translate } ) => (
						<Fragment>
							<p>{ translate( 'You published your first blog post.' ) }</p>
						</Fragment>
					) }
				</Step>
			</Tour>
		);

		expect( tourBranching( tourTree ) ).toEqual( {
			init: {
				next: 'categories-tags',
				continue: 'categories-tags',
			},
			'categories-tags': {
				next: 'featured-images',
			},
			'featured-images': {
				continue: 'choose-image',
			},
			'choose-image': {
				next: 'click-set-featured-image',
			},
			'click-set-featured-image': {
				continue: 'click-update',
			},
			'click-update': {
				continue: 'finish',
			},
			finish: {},
		} );
	} );
} );