| 
									
										
										
										
											2020-07-17 21:03:23 +02:00
										 |  |  | /* global cy */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const selectors = { | 
					
						
							|  |  |  |   defaultOutput: '.output-text', | 
					
						
							| 
									
										
										
										
											2020-08-25 19:28:27 +02:00
										 |  |  |   editor: '.monaco-editor', | 
					
						
							| 
									
										
										
										
											2020-07-17 21:03:23 +02:00
										 |  |  |   hotkeys: '.default-layout > div', | 
					
						
							|  |  |  |   runTestsButton: 'button:contains("Run the Tests")' | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const locations = { | 
					
						
							|  |  |  |   index: | 
					
						
							|  |  |  |     '/learn/responsive-web-design/basic-html-and-html5/' + | 
					
						
							|  |  |  |     'say-hello-to-html-elements' | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const defaultOutput = `
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2020-12-16 02:02:52 -06:00
										 |  |  | * Your test output will go here | 
					
						
							| 
									
										
										
										
											2020-07-17 21:03:23 +02:00
										 |  |  | */`; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-28 16:04:07 +02:00
										 |  |  | const runningOutput = '// running tests'; | 
					
						
							|  |  |  | const finishedOutput = '// tests completed'; | 
					
						
							| 
									
										
										
										
											2020-07-17 21:03:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-11 00:31:46 +05:30
										 |  |  | describe('Classic challenge', function () { | 
					
						
							| 
									
										
										
										
											2021-04-28 16:04:07 +02:00
										 |  |  |   before(() => { | 
					
						
							| 
									
										
										
										
											2020-07-17 21:03:23 +02:00
										 |  |  |     cy.visit(locations.index); | 
					
						
							| 
									
										
										
										
											2021-04-28 16:04:07 +02:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2020-07-17 21:03:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-28 16:04:07 +02:00
										 |  |  |   it('renders the default output text', () => { | 
					
						
							| 
									
										
										
										
											2020-07-17 21:03:23 +02:00
										 |  |  |     cy.title().should( | 
					
						
							|  |  |  |       'eq', | 
					
						
							|  |  |  |       'Learn Basic HTML and HTML5: Say Hello to HTML Elements |' + | 
					
						
							|  |  |  |         ' freeCodeCamp.org' | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     cy.get(selectors.defaultOutput).contains(defaultOutput); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-28 16:04:07 +02:00
										 |  |  |   it('shows test output when the tests are run', () => { | 
					
						
							|  |  |  |     // first wait for the editor to load
 | 
					
						
							|  |  |  |     cy.get(selectors.editor, { timeout: 15000 }); | 
					
						
							|  |  |  |     cy.get(selectors.runTestsButton) | 
					
						
							|  |  |  |       .click() | 
					
						
							|  |  |  |       .then(() => { | 
					
						
							|  |  |  |         cy.get(selectors.defaultOutput) | 
					
						
							|  |  |  |           .contains(runningOutput) | 
					
						
							|  |  |  |           .contains(finishedOutput); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2021-02-09 14:15:18 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-28 16:04:07 +02:00
										 |  |  |   it('shows test output when the tests are triggered by the keyboard', () => { | 
					
						
							|  |  |  |     // first wait for the editor to load
 | 
					
						
							|  |  |  |     cy.get(selectors.editor, { | 
					
						
							|  |  |  |       timeout: 15000 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     cy.get(selectors.hotkeys) | 
					
						
							|  |  |  |       .focus() | 
					
						
							|  |  |  |       .type('{ctrl}{enter}') | 
					
						
							|  |  |  |       .then(() => { | 
					
						
							|  |  |  |         cy.get(selectors.defaultOutput) | 
					
						
							|  |  |  |           .contains(runningOutput) | 
					
						
							|  |  |  |           .contains(finishedOutput); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2020-07-17 21:03:23 +02:00
										 |  |  | }); |