| 
									
										
										
										
											2013-07-17 16:28:14 +08:00
										 |  |  | <body> | 
					
						
							| 
									
										
										
										
											2019-12-16 18:15:12 -08:00
										 |  |  | <script src="jquery-2.0.3.min.js"></script> | 
					
						
							| 
									
										
										
										
											2013-07-17 16:28:14 +08:00
										 |  |  | <script type="text/javascript" charset="utf-8"> | 
					
						
							| 
									
										
										
										
											2020-05-28 00:21:02 +02:00
										 |  |  | (async function() { | 
					
						
							| 
									
										
										
										
											2018-07-29 18:27:58 -07:00
										 |  |  |   // Deprecated APIs are still supported and should be tested. | 
					
						
							|  |  |  |   process.throwDeprecation = false | 
					
						
							| 
									
										
										
										
											2013-12-15 17:02:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-28 12:18:33 +01:00
										 |  |  |   const path = require('path') | 
					
						
							|  |  |  |   const electron = require('electron') | 
					
						
							| 
									
										
										
										
											2019-10-30 16:38:21 -07:00
										 |  |  |   const { ipcRenderer } = electron | 
					
						
							| 
									
										
										
										
											2015-11-12 18:28:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-11 17:07:11 -07:00
										 |  |  |   // Set up chai-as-promised here first to avoid conflicts | 
					
						
							|  |  |  |   // It must be loaded first or really strange things happen inside | 
					
						
							|  |  |  |   // chai that cause test failures | 
					
						
							|  |  |  |   // DO NOT MOVE, REMOVE OR EDIT THIS LINE | 
					
						
							|  |  |  |   require('chai').use(require('chai-as-promised')) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 11:15:22 +08:00
										 |  |  |   // Rediret all output to browser. | 
					
						
							| 
									
										
										
										
											2019-10-30 16:38:21 -07:00
										 |  |  |   const fakeConsole = {} | 
					
						
							|  |  |  |   for (const k in console) { | 
					
						
							|  |  |  |     if (console.hasOwnProperty(k) && k !== 'assert') { | 
					
						
							|  |  |  |       fakeConsole[k] = (...args) => ipcRenderer.send('console-call', k, args) | 
					
						
							| 
									
										
										
										
											2019-06-13 15:56:58 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-08-25 20:54:15 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-10-30 16:38:21 -07:00
										 |  |  |   global.__defineGetter__('console', function () { | 
					
						
							|  |  |  |     return fakeConsole | 
					
						
							|  |  |  |   }) | 
					
						
							| 
									
										
										
										
											2013-08-21 11:15:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-28 12:18:33 +01:00
										 |  |  |   const Mocha = require('mocha') | 
					
						
							| 
									
										
										
										
											2018-09-14 14:56:16 -04:00
										 |  |  |   const mochaOptions = {} | 
					
						
							|  |  |  |   if (process.env.MOCHA_REPORTER) { | 
					
						
							|  |  |  |     mochaOptions.reporter = process.env.MOCHA_REPORTER | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (process.env.MOCHA_MULTI_REPORTERS) { | 
					
						
							|  |  |  |     mochaOptions.reporterOptions = { | 
					
						
							|  |  |  |       reporterEnabled: process.env.MOCHA_MULTI_REPORTERS | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   const mocha = new Mocha(mochaOptions) | 
					
						
							| 
									
										
										
										
											2013-07-17 16:28:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-28 13:05:42 -04:00
										 |  |  |   if (!process.env.MOCHA_REPORTER) { | 
					
						
							| 
									
										
										
										
											2019-10-30 16:38:21 -07:00
										 |  |  |     mocha.ui('bdd').reporter('tap') | 
					
						
							| 
									
										
										
										
											2017-09-28 13:05:42 -04:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-05-18 12:33:54 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const mochaTimeout = process.env.MOCHA_TIMEOUT || 30000 | 
					
						
							|  |  |  |   mocha.timeout(mochaTimeout) | 
					
						
							| 
									
										
										
										
											2013-07-17 16:28:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-28 12:18:33 +01:00
										 |  |  |   const query = Mocha.utils.parseQuery(window.location.search || '') | 
					
						
							|  |  |  |   if (query.grep) mocha.grep(query.grep) | 
					
						
							|  |  |  |   if (query.invert) mocha.invert() | 
					
						
							| 
									
										
										
										
											2013-07-17 16:28:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-28 00:21:02 +02:00
										 |  |  |   const filter = (file) => { | 
					
						
							|  |  |  |     if (!/-spec\.js$/.test(file)) { | 
					
						
							|  |  |  |       return false | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-28 12:18:33 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-28 00:21:02 +02:00
										 |  |  |     // This allows you to run specific modules only: | 
					
						
							|  |  |  |     // npm run test -match=menu | 
					
						
							|  |  |  |     const moduleMatch = process.env.npm_config_match | 
					
						
							|  |  |  |       ? new RegExp(process.env.npm_config_match, 'g') | 
					
						
							|  |  |  |       : null | 
					
						
							|  |  |  |     if (moduleMatch && !moduleMatch.test(file)) { | 
					
						
							|  |  |  |       return false | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-17 16:28:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-28 00:21:02 +02:00
										 |  |  |     const files = query.files ? query.files.split(',') : undefined | 
					
						
							|  |  |  |     const baseElectronDir = path.resolve(__dirname, '..', '..') | 
					
						
							|  |  |  |     if (files && !files.includes(path.relative(baseElectronDir, file))) { | 
					
						
							|  |  |  |       return false | 
					
						
							| 
									
										
										
										
											2017-12-28 12:18:33 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-17 16:28:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-28 00:21:02 +02:00
										 |  |  |     return true | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-11-06 16:15:55 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-28 00:21:02 +02:00
										 |  |  |   const getFiles = require('./get-files') | 
					
						
							|  |  |  |   const testFiles = await getFiles(path.dirname(__dirname), { filter }) | 
					
						
							|  |  |  |   testFiles.sort().forEach((file) => { | 
					
						
							|  |  |  |     mocha.addFile(file) | 
					
						
							|  |  |  |   }) | 
					
						
							| 
									
										
										
										
											2019-11-06 16:15:55 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-28 00:21:02 +02:00
										 |  |  |   // Set up chai in the correct order | 
					
						
							|  |  |  |   const chai = require('chai') | 
					
						
							|  |  |  |   chai.use(require('chai-as-promised')) | 
					
						
							|  |  |  |   chai.use(require('dirty-chai')) | 
					
						
							| 
									
										
										
										
											2017-12-28 12:18:33 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-28 00:21:02 +02:00
										 |  |  |   const runner = mocha.run(() => { | 
					
						
							|  |  |  |     // Ensure the callback is called after runner is defined | 
					
						
							|  |  |  |     setTimeout(() => { | 
					
						
							|  |  |  |       ipcRenderer.send('process.exit', runner.failures) | 
					
						
							|  |  |  |     }, 0) | 
					
						
							| 
									
										
										
										
											2017-12-28 12:18:33 +01:00
										 |  |  |   }) | 
					
						
							|  |  |  | })() | 
					
						
							| 
									
										
										
										
											2013-07-17 16:28:14 +08:00
										 |  |  | </script> | 
					
						
							|  |  |  | </body> |