DEV: Better handling of no results (#205)
When there were no query results it would throw an error due to `this.resultCount` always passing as it is in the format of ``` "INTEGER - results returned" ``` so we need to grab the first index of the string and check if the integer is great than 0
This commit is contained in:
parent
4c70cfa100
commit
85c88c5d80
|
@ -126,7 +126,7 @@ export default class QueryResult extends Component {
|
||||||
get canShowChart() {
|
get canShowChart() {
|
||||||
const hasTwoColumns = this.colCount === 2;
|
const hasTwoColumns = this.colCount === 2;
|
||||||
const secondColumnContainsNumber =
|
const secondColumnContainsNumber =
|
||||||
this.resultCount.length && typeof this.rows[0][1] === "number";
|
this.resultCount[0] > 0 && typeof this.rows[0][1] === "number";
|
||||||
const secondColumnContainsId = this.colRender[1];
|
const secondColumnContainsId = this.colRender[1];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -326,5 +326,23 @@ discourseModule(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
componentTest("it handles no results", {
|
||||||
|
template: hbs`<QueryResult @content={{content}} />`,
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
const results = {
|
||||||
|
colrender: [],
|
||||||
|
result_count: 0,
|
||||||
|
columns: ["user_name", "like_count", "post_count"],
|
||||||
|
rows: [],
|
||||||
|
};
|
||||||
|
this.set("content", results);
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
assert.ok(!exists("table tbody tr"), "renders no results");
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue