Skip to content

Commit

Permalink
fix: Add support for atoms
Browse files Browse the repository at this point in the history
Fixes #60
  • Loading branch information
OiNutter committed Sep 15, 2021
1 parent ffebd86 commit 4805bdd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/ResultsWindow.tsx
Expand Up @@ -21,6 +21,7 @@ import { ipcRenderer } from "electron";

import {
agWrapper,
preBlock,
resultsWindow,
resultsWrapper,
stackTokens,
Expand Down Expand Up @@ -66,8 +67,9 @@ const ResultsWindow: FunctionComponent<ResultsWindowProps> = ({
let rows: Array<{} | string> = [];
let columns: Array<IColumn> = [];

let processed;
if (currentResults) {
const processed = ResultsProcessor.process(currentResults);
processed = ResultsProcessor.process(currentResults);

if (Array.isArray(processed)) {
if (
Expand Down Expand Up @@ -247,7 +249,7 @@ const ResultsWindow: FunctionComponent<ResultsWindowProps> = ({
</MessageBar>
) : (
<>
{typeof currentResults === "string" ||
{typeof processed === "string" ||
currentView === ResultsView.Raw ? (
<pre className="raw-results-view">
{currentResults ? stringify(currentResults) : ""}
Expand Down
7 changes: 5 additions & 2 deletions src/results/processor.ts
Expand Up @@ -7,6 +7,8 @@ export class ResultsProcessor {
let cols: ColDef[] = [],
rows: Array<{} | null> = [];

console.log("results", results, typeof results);

// Get the type of our results
if (Array.isArray(results)) {
// We have a list of results, lets convert them to our format for details list
Expand All @@ -25,10 +27,11 @@ export class ResultsProcessor {
//sorted = this.copyAndSort(this.preprocessData(prepped), sortColumn, sortDirection == "desc")
cols = this.prepareHeaders({ key: "", value: "" }, false);
return [cols, rows];
} else if (typeof results === "string") {
} else if (typeof results === "string" || results.toString()) {
// If it's a string just return it as is
return results;
return results.toString();
} else {
console.log("Couldn't Parse");
// If we can't do anything with the results return an error and results as string
return `Resultset could not be parsed.\n\n${JSON.stringify(results)}`;
}
Expand Down
4 changes: 4 additions & 0 deletions src/style.ts
Expand Up @@ -113,3 +113,7 @@ export const stackTokens: IStackTokens = {
childrenGap: 10,
padding: 10,
};

export const preBlock: CSSProperties = {
padding: 10,
};
17 changes: 17 additions & 0 deletions tests/results.js
Expand Up @@ -37,6 +37,23 @@ describe("Results Window", function () {
assert.strictEqual(await resultsView.innerText(), `"${query}"`);
});

it("should dislay an atom correctly", async function () {
this.timeout(20000);
this.retries(2);

const editor = await this.appWindow.$(".monaco-editor textarea");

const query = "2+2";
await editor.press(`${isMac ? "Meta" : "Control"}+a`);
await editor.type(query);
await editor.press(`${isMac ? "Meta" : "Control"}+Enter`);

const resultsView = await this.appWindow.waitForSelector(
".raw-results-view"
);
assert.strictEqual(await resultsView.innerText(), `4`);
});

it("should display a dictionary correctly", async function () {
this.timeout(20000);
this.retries(2);
Expand Down

0 comments on commit 4805bdd

Please sign in to comment.