hide recent documents if there aren't any

Signed-off-by: Stepan Usatyuk <usaatyuk@ustk.me>
This commit is contained in:
2019-05-15 00:46:11 +03:00
parent 66abd85149
commit 4887fb0731
3 changed files with 53 additions and 26 deletions

View File

@@ -4098,14 +4098,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -4120,20 +4118,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@@ -4250,8 +4245,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@@ -4263,7 +4257,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -4278,7 +4271,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -4286,14 +4278,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -4312,7 +4302,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -4393,8 +4382,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@@ -4406,7 +4394,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@@ -4528,7 +4515,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",

View File

@@ -35,11 +35,15 @@ export class OverviewComponent extends React.PureComponent<
const recentCut = recent.splice(0, 4);
return (
<div id="overview">
<div className="section">
<H3>Recent</H3>
<DocumentsList docs={recentCut} />
</div>
<span className="separator" />
{recentCut.length !== 0 && (
<>
<div className="section">
<H3>Recent</H3>
<DocumentsList docs={recentCut} />
</div>
<span className="separator" />
</>
)}
<div className="section">
<H3>All documents</H3>
<DocumentsList docs={docs} newDocument={true} />

View File

@@ -0,0 +1,37 @@
import * as React from "react";
import { H3 } from "@blueprintjs/core";
import { shallow } from "enzyme";
import { OverviewComponent } from "../Overview";
afterEach(() => {
jest.restoreAllMocks();
});
describe("<CodeBlock />", () => {
it("should not show recent docs if there aren't any", () => {
const wrapper = shallow(
<OverviewComponent
allDocs={{}}
fetching={false}
spinner={false}
fetchDocs={() => {}}
/>,
);
expect(wrapper.find(H3)).toHaveLength(1);
});
it("show recent docs if there are some", () => {
const wrapper = shallow(
<OverviewComponent
allDocs={{ 1: { id: 1 } } as any}
fetching={false}
spinner={false}
fetchDocs={() => {}}
/>,
);
expect(wrapper.find(H3)).toHaveLength(2);
});
});