-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i586 - on click download button it will be disabled for 5 seconds #107
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f435f8e
* on click download button it will be disabled for 5 seconds
kalininj ca0b3d7
* Changed default interface for local state to undefined if not neede…
kalininj 66647f6
* move props on first level for DownloadCoverageContentComponent
kalininj 2b97eea
renamed onClick to internalOnClickHandler and onClickOuterEvent to on…
kalininj 9e4bd6a
fixed storevalues function, removed unnecessary timeout parameter
kalininj 98fedba
made important properties of DownloadCoverageComponent not optional
kalininj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import * as React from "react"; | ||
import { expect } from "chai"; | ||
import { mockCoverageSet, mockScenario, mockTouchstone } from "../../../mocks/mockModels"; | ||
import { shallow, ShallowWrapper } from "enzyme"; | ||
import { shallow, ShallowWrapper, mount } from "enzyme"; | ||
|
||
import { | ||
DownloadCoverageContentComponent, | ||
|
@@ -45,6 +45,7 @@ describe("DownloadCoverageContentComponent", () => { | |
expect(rendered.find(OneTimeButton).props()).to.eql({ | ||
token: "TOKEN", | ||
refreshToken: (rendered.instance() as DownloadCoverageContentComponent).refreshToken, | ||
onClickOuterEvent: (rendered.instance() as DownloadCoverageContentComponent).onDownloadClicked, | ||
enabled: true, | ||
children: "Download combined coverage set data in CSV format" | ||
}); | ||
|
@@ -53,11 +54,33 @@ describe("DownloadCoverageContentComponent", () => { | |
it("refreshToken triggers token refresh", () => { | ||
const spy = sandbox.dispatchSpy(); | ||
const fetchNewToken = sandbox.stubFetch(responsibilityStore, "fetchOneTimeCoverageToken"); | ||
new DownloadCoverageContentComponent().refreshToken(); | ||
const props = makeProps({ready: true}); | ||
const component = shallow(<DownloadCoverageContentComponent {...props} />); | ||
const instance = component.instance() as DownloadCoverageContentComponent; | ||
instance.refreshToken(); | ||
expectOneAction(spy, { action: "CoverageTokenActions.clearUsedToken" }); | ||
expect(fetchNewToken.called).to.be.true; | ||
}); | ||
|
||
it("calling meth onDownloadClicked sets state prop downloadButtonEnabled to false after given timeout in 100ms", function(done: DoneCallback) { | ||
this.timeout(140); | ||
const props = makeProps({ | ||
coverageToken: "TOKEN", | ||
downloadButtonDisableTimeout: 100, | ||
}); | ||
const component = shallow(<DownloadCoverageContentComponent {...props} />); | ||
const instance = component.instance() as DownloadCoverageContentComponent; | ||
expect(component.state().downloadButtonEnabled).to.be.equal(true) | ||
instance.onDownloadClicked(); | ||
setTimeout(() => { | ||
expect(component.state().downloadButtonEnabled).to.be.equal(false) | ||
},70); | ||
setTimeout(() => { | ||
expect(component.state().downloadButtonEnabled).to.be.equal(true) | ||
done(); | ||
},110); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this makes this test take 5 seconds to run which is a bit long. Maybe parameterize the delay (via a React prop) so you can test this more rapidly? |
||
|
||
it("renders format control", () => { | ||
const props = makeProps({ selectedFormat: "x" }); | ||
const rendered = shallow(<DownloadCoverageContentComponent {...props} />); | ||
|
@@ -91,11 +114,10 @@ function makeProps(props: any): DownloadCoverageComponentProps { | |
const scenario = mockScenario(); | ||
return { | ||
ready: true, | ||
props: Object.assign({ | ||
touchstone, | ||
scenario, | ||
coverageSets: [], | ||
coverageToken: null, | ||
}, props) | ||
touchstone, | ||
scenario, | ||
coverageSets: [], | ||
coverageToken: null, | ||
...props | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could just be called
onClick
. Better to have it easy to understand for components using theOneTimeButton
. If you'd like to keep things unambiguous, maybe rename the internal method to something likeinternalOnClickHandler
.