microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
test/extension/elementInspector.test.ts
40lines · 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 | |
| 7 | |
| 8 | suite("elementInspector", function() { |
| 9 | suite("extensionContext", function () { |
| 10 | |
| 11 | test("element inspector should run and closed without errors", function(done: MochaDone) { |
| 12 | CommandPaletteHandler.runElementInspector(); |
| 13 | assert.notEqual(CommandPaletteHandler.elementInspector, null); |
| 14 | |
| 15 | if (CommandPaletteHandler.elementInspector) { |
| 16 | CommandPaletteHandler.elementInspector.once("exit", () => { |
| 17 | assert.equal(CommandPaletteHandler.elementInspector, null); |
| 18 | done(); |
| 19 | }); |
| 20 | } else { |
| 21 | assert.ifError("element inspector didn't launch properly"); |
| 22 | } |
| 23 | CommandPaletteHandler.stopElementInspector(); |
| 24 | }); |
| 25 | |
| 26 | test("element inspector should not allow multiple windows to run", function(done: MochaDone) { |
| 27 | CommandPaletteHandler.runElementInspector(); |
| 28 | if (CommandPaletteHandler.elementInspector) { |
| 29 | let PID = CommandPaletteHandler.elementInspector.pid; |
| 30 | CommandPaletteHandler.runElementInspector(); |
| 31 | assert.equal(CommandPaletteHandler.elementInspector.pid, PID); |
| 32 | CommandPaletteHandler.stopElementInspector(); |
| 33 | done(); |
| 34 | } else { |
| 35 | assert.ifError("element inspector didn't launch properly"); |
| 36 | } |
| 37 | }); |
| 38 | }); |
| 39 | |
| 40 | }); |