microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
test/extension/elementInspector.test.ts
44lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | |
| 4 | import { CommandPaletteHandler } from "../../src/extension/commandPaletteHandler"; |
| 5 | import * as assert from "assert"; |
| 6 | import * as fs from "fs"; |
| 7 | import * as path from "path"; |
| 8 | |
| 9 | |
| 10 | suite("elementInspector", function() { |
| 11 | suite("extensionContext", function () { |
| 12 | |
| 13 | test("element inspector should run and closed without errors", function(done: MochaDone) { |
| 14 | const devToolsPath = path.resolve(__dirname, "..", "..", "node_modules", "react-devtools", "app.js"); |
| 15 | assert.equal(fs.existsSync(devToolsPath), true); |
| 16 | CommandPaletteHandler.runElementInspector(); |
| 17 | assert.notEqual(CommandPaletteHandler.elementInspector, null); |
| 18 | |
| 19 | if (CommandPaletteHandler.elementInspector) { |
| 20 | CommandPaletteHandler.elementInspector.once("exit", () => { |
| 21 | assert.equal(CommandPaletteHandler.elementInspector, null); |
| 22 | done(); |
| 23 | }); |
| 24 | } else { |
| 25 | assert.ifError("element inspector didn't launch properly"); |
| 26 | } |
| 27 | CommandPaletteHandler.stopElementInspector(); |
| 28 | }); |
| 29 | |
| 30 | test("element inspector should not allow multiple windows to run", function(done: MochaDone) { |
| 31 | CommandPaletteHandler.runElementInspector(); |
| 32 | if (CommandPaletteHandler.elementInspector) { |
| 33 | let PID = CommandPaletteHandler.elementInspector.pid; |
| 34 | CommandPaletteHandler.runElementInspector(); |
| 35 | assert.equal(CommandPaletteHandler.elementInspector.pid, PID); |
| 36 | CommandPaletteHandler.stopElementInspector(); |
| 37 | done(); |
| 38 | } else { |
| 39 | assert.ifError("element inspector didn't launch properly"); |
| 40 | } |
| 41 | }); |
| 42 | }); |
| 43 | |
| 44 | }); |