os download page updates

pull/1686/head
gabrielburnworth 2020-02-07 15:05:59 -08:00
parent 464b730cd8
commit e46b4de0bb
3 changed files with 13 additions and 7 deletions

View File

@ -1579,7 +1579,7 @@ textarea:focus {
}
}
table {
margin: 2rem;
margin: auto;
margin-top: 3rem;
width: 93%;
font-size: 1.2rem;
@ -1596,6 +1596,7 @@ textarea:focus {
padding-bottom: 1rem;
span {
display: block;
white-space: nowrap;
}
}
}

View File

@ -13,12 +13,14 @@ import * as React from "react";
import { mount } from "enzyme";
import { OsDownload } from "../content";
const DOWNLOAD_PREFIX = "DOWNLOAD ";
describe("<OsDownload />", () => {
it("fetches and renders", async () => {
const wrapper = await mount<OsDownload>(<OsDownload />);
expect(wrapper.state().tagName).toEqual("v1.0.0");
expect(wrapper.state().genesisImg).toEqual("fake rpi3 img url");
expect(wrapper.text()).toContain("Download FBOS v1.0.0");
expect(wrapper.text()).toContain(DOWNLOAD_PREFIX + "v1.0.0");
wrapper.update();
expect(wrapper.find("a").first().props().href)
.toEqual("fake rpi3 img url");
@ -28,7 +30,7 @@ describe("<OsDownload />", () => {
globalConfig.GENESIS_IMG_FALLBACK = "fake rpi3 img fallback url///////v0.0.0";
mockResponse = Promise.reject();
const wrapper = await mount(<OsDownload />);
expect(wrapper.text()).toContain("Download FBOS v0.0.0");
expect(wrapper.text()).toContain(DOWNLOAD_PREFIX + "v0.0.0");
expect(wrapper.find("a").first().props().href)
.toEqual(globalConfig.GENESIS_IMG_FALLBACK);
});
@ -36,7 +38,7 @@ describe("<OsDownload />", () => {
it("uses override", async () => {
globalConfig.GENESIS_IMG_OVERRIDE = "fake rpi3 img override url";
const wrapper = await mount(<OsDownload />);
expect(wrapper.text()).toContain("Download FBOS");
expect(wrapper.text()).toContain(DOWNLOAD_PREFIX);
wrapper.update();
expect(wrapper.find("a").first().props().href)
.toEqual(globalConfig.GENESIS_IMG_OVERRIDE);

View File

@ -22,6 +22,9 @@ const tagNameFromUrl = (url: string) => {
return tagPart.startsWith("v") ? tagPart : "";
};
const downloadButtonText = (versionString: string) =>
`${t("DOWNLOAD")} ${versionString}`;
export class OsDownload extends React.Component<{}, OsDownloadState> {
state: OsDownloadState = { tagName: "", genesisImg: "", expressImg: "" };
@ -75,15 +78,15 @@ export class OsDownload extends React.Component<{}, OsDownloadState> {
<span>{"Genesis v1.2"}</span>
<span>{"Genesis v1.3"}</span>
<span>{"Genesis v1.4"}</span>
<span>{"Genesis XL v1.4"}</span>
<span>{"Genesis v1.5"}</span>
<span>{"Genesis XL v1.4"}</span>
<span>{"Genesis XL v1.5"}</span>
</td>
<td>{t("Raspberry Pi 3")}</td>
<td>
<a className="transparent-link-button"
href={this.genesisImgDownloadLink}>
{`${t("Download")} FBOS ${this.genesisTagName}`}
{downloadButtonText(this.genesisTagName)}
</a>
</td>
</tr>
@ -96,7 +99,7 @@ export class OsDownload extends React.Component<{}, OsDownloadState> {
<td>
<a className="transparent-link-button"
href={this.expressImgDownloadLink}>
{`${t("Download")} FBOS ${this.expressTagName}`}
{downloadButtonText(this.expressTagName)}
</a>
</td>
</tr>