@@ -83,3 +83,70 @@ test('It should return the latest launch', () => {
83
83
expect ( response . statusCode ) . toBe ( 200 ) ;
84
84
} ) ;
85
85
} ) ;
86
+
87
+
88
+ //------------------------------------------------------------
89
+ // Launch Info Test
90
+ //------------------------------------------------------------
91
+
92
+ test ( 'It should return a specific Launch info' , ( ) => {
93
+ return request ( app . listen ( ) ) . get ( '/v2/launches/all?flight_number=40' ) . then ( ( response ) => {
94
+ expect ( response . statusCode ) . toBe ( 200 ) ;
95
+ response . body . forEach ( ( item ) => {
96
+ expect ( item ) . toHaveProperty ( 'flight_number' , expect . anything ( ) ) ;
97
+ expect ( item ) . toHaveProperty ( 'launch_year' , expect . stringMatching ( / ^ [ 0 - 9 ] { 4 } $ / ) ) ;
98
+ expect ( item ) . toHaveProperty ( 'launch_date_unix' ) ;
99
+ expect ( item ) . toHaveProperty ( 'launch_date_utc' , expect . anything ( ) ) ;
100
+ expect ( item ) . toHaveProperty ( 'launch_date_local' , expect . anything ( ) ) ;
101
+ expect ( item ) . toHaveProperty ( 'rocket.rocket_id' ) ;
102
+ expect ( item ) . toHaveProperty ( 'rocket.rocket_name' ) ;
103
+ expect ( item ) . toHaveProperty ( 'rocket.rocket_type' ) ;
104
+ expect ( item . rocket . first_stage . cores . length ) . toBeGreaterThan ( 0 ) ;
105
+ item . rocket . first_stage . cores . forEach ( ( core ) => {
106
+ expect ( core ) . toHaveProperty ( 'core_serial' ) ;
107
+ expect ( core ) . toHaveProperty ( 'flight' , expect . any ( Number ) ) ;
108
+ expect ( core ) . toHaveProperty ( 'reused' ) ;
109
+ expect ( core ) . toHaveProperty ( 'land_success' ) ;
110
+ expect ( core ) . toHaveProperty ( 'landing_type' ) ;
111
+ expect ( core ) . toHaveProperty ( 'landing_vehicle' ) ;
112
+ } ) ;
113
+ expect ( item . rocket . second_stage . payloads . length ) . toBeGreaterThan ( 0 ) ;
114
+ if ( item . hasOwnProperty . call ( 'cap_serial' ) ) {
115
+ item . rocket . second_stage . payloads . forEach ( ( payload ) => {
116
+ expect ( payload ) . toHaveProperty ( 'payload_id' ) ;
117
+ expect ( payload ) . toHaveProperty ( 'reused' ) ;
118
+ expect ( payload ) . toHaveProperty ( 'cap_serial' ) ;
119
+ expect ( payload . customers . length ) . toBeGreaterThan ( 0 ) ;
120
+ expect ( payload ) . toHaveProperty ( 'payload_mass_kg' ) ;
121
+ expect ( payload ) . toHaveProperty ( 'payload_mass_lbs' ) ;
122
+ expect ( payload ) . toHaveProperty ( 'orbit' ) ;
123
+ expect ( payload ) . toHaveProperty ( 'mass_returned_kg' ) ;
124
+ expect ( payload ) . toHaveProperty ( 'mass_returned_lbs' ) ;
125
+ expect ( payload ) . toHaveProperty ( 'flight_time_sec' ) ;
126
+ expect ( payload ) . toHaveProperty ( 'cargo_manifest' ) ;
127
+ } ) ;
128
+ } else {
129
+ item . rocket . second_stage . payloads . forEach ( ( payload ) => {
130
+ expect ( payload ) . toHaveProperty ( 'payload_id' ) ;
131
+ expect ( payload ) . toHaveProperty ( 'reused' ) ;
132
+ expect ( payload . customers . length ) . toBeGreaterThan ( 0 ) ;
133
+ expect ( payload ) . toHaveProperty ( 'payload_mass_kg' ) ;
134
+ expect ( payload ) . toHaveProperty ( 'payload_mass_lbs' ) ;
135
+ expect ( payload ) . toHaveProperty ( 'orbit' ) ;
136
+ } ) ;
137
+ }
138
+ expect ( item ) . toHaveProperty ( 'telemetry.flight_club' ) ;
139
+ expect ( item ) . toHaveProperty ( 'reuse.core' ) ;
140
+ expect ( item ) . toHaveProperty ( 'reuse.side_core1' ) ;
141
+ expect ( item ) . toHaveProperty ( 'reuse.side_core2' ) ;
142
+ expect ( item ) . toHaveProperty ( 'reuse.fairings' ) ;
143
+ expect ( item ) . toHaveProperty ( 'reuse.capsule' ) ;
144
+ expect ( item ) . toHaveProperty ( 'launch_site.site_id' ) ;
145
+ expect ( item ) . toHaveProperty ( 'launch_site.site_name' ) ;
146
+ expect ( item ) . toHaveProperty ( 'launch_site.site_name_long' ) ;
147
+ expect ( item ) . toHaveProperty ( 'launch_success' ) ;
148
+ expect ( item ) . toHaveProperty ( 'links' ) ;
149
+ expect ( item ) . toHaveProperty ( 'details' ) ;
150
+ } ) ;
151
+ } ) ;
152
+ } ) ;
0 commit comments