Skip to content

Commit

Permalink
adding more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mletter1 committed Mar 26, 2020
1 parent e2dfdb3 commit b9c37b2
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

import React from 'react';
import LoadingPage from "slycat-timeseries-model/plugin-components/LoadingPage.tsx";
import {LoadingPageProps, LoadingPageState} from "slycat-timeseries-model/plugin-components/types.ts";
import { mount, shallow } from "enzyme";


describe('Timeseries LoadingPage',() =>{
const render = mount(
<LoadingPage
modelId={'modelID'}
modelState={'waiting'}
jid={'1234'}
hostname={'hostname'}
/>
);
test('should be Defined', () => {
expect(LoadingPage).toBeDefined();
});
test('we have expected props on initial load', () => {
const props = render.props() as LoadingPageProps;
expect(props).toMatchSnapshot();
});
test('we have expected state on initial load', () => {
const state = render.state() as LoadingPageState;
expect(state).toMatchSnapshot();
});
test('we have expected props on initial load', () => {
const myDate = new Date('2019-05-14T11:01:58/135Z');
global.Date = jest.fn(() => myDate);
const test = shallow(
<LoadingPage
modelId={'modelID'}
modelState={'waiting'}
jid={'1234'}
hostname={'hostname'}
/>
);
expect(test).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Timeseries LoadingPage we have expected props on initial load 1`] = `
Object {
"hostname": "hostname",
"jid": "1234",
"modelId": "modelID",
"modelState": "waiting",
}
`;

exports[`Timeseries LoadingPage we have expected props on initial load 2`] = `
<div
className="slycat-job-checker bootstrap-styles"
>
<div>
<ProgressBar
hidden={false}
progress={0}
/>
</div>
<div
className="slycat-job-checker-controls"
>
<div
className="row"
>
<div
className="col-3"
>
Updated
NaN-NaN-NaN NaN:NaN:NaN
</div>
<div
className="col-2"
>
Job id:
<b>
1234
</b>
</div>
<div
className="col-3"
>
Remote host:
<b>
hostname
</b>
</div>
<div
className="col-2"
>
Session:
<b>
false
</b>
</div>
<div
className="col-2"
>
<div>
<ConnectModal
callBack={[Function]}
hostname="hostname"
modalId="ConnectModal"
/>
<button
className="btn btn-md btn-primary"
disabled={true}
id="pullbtn"
onClick={[Function]}
title="load data"
type="button"
>
load
</button>
</div>
</div>
</div>
<div
className="row"
>
<button
aria-controls="collapseExample"
aria-expanded="false"
className="btn btn-primary"
data-target="#collapseExample"
data-toggle="collapse"
type="button"
>
Show job status meanings
</button>
<JobCodes />
</div>
</div>
<div
className="slycat-job-checker-output text-white bg-secondary"
>
<Spinner />
</div>
</div>
`;

exports[`Timeseries LoadingPage we have expected state on initial load 1`] = `
Object {
"jobStatus": "Job Status Unknown",
"log": Object {
"logLineArray": Array [],
},
"modalId": "ConnectModal",
"modelId": "modelID",
"modelMessage": "",
"modelShow": false,
"modelState": "waiting",
"progressBarHidden": false,
"progressBarProgress": 0,
"pullCalled": 0,
"sessionExists": false,
}
`;
36 changes: 18 additions & 18 deletions web-server/plugins/slycat-timeseries-model/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,23 @@ $(document).ready(function() {
}
},
});

const showLoadingPage = () => {
client.get_model_fetch(model._id).then((modelResponse) => {
ReactDOM.render(
<LoadingPage
modelId={modelResponse._id}
modelState={modelResponse["state"]}
jid={modelResponse['artifact:jid']}
hostname={modelResponse['artifact:hostname']?modelResponse['artifact:hostname']:"missing"}
/>,
document.querySelector('#timeseries-model')
);
}
).catch((msg) => {
// eslint-disable-next-line no-alert
window.alert(`Error retrieving model: ${msg}`);
})
};
//////////////////////////////////////////////////////////////////////////////////////////
// Get the model
//////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -210,23 +226,7 @@ $(document).ready(function() {
}
});
}
const showLoadingPage = () => {
client.get_model_fetch(model._id).then((modelResponse) => {
ReactDOM.render(
<LoadingPage
modelId={modelResponse._id}
modelState={modelResponse["state"]}
jid={modelResponse['artifact:jid']}
hostname={modelResponse['artifact:hostname']?modelResponse['artifact:hostname']:"missing"}
/>,
document.querySelector('#timeseries-model')
);
}
).catch((msg) => {
// eslint-disable-next-line no-alert
window.alert(`Error retrieving model: ${msg}`);
})
};

// showLoadingPage();
loadPage()
//////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit b9c37b2

Please sign in to comment.