-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: hide NMRium button on non-NMR layouts
Co-authored-by: Lan Le <[email protected]> Refs: #1460
- Loading branch information
1 parent
aa30d08
commit f75d554
Showing
4 changed files
with
382 additions
and
15 deletions.
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
105 changes: 105 additions & 0 deletions
105
...cks/src/apps/mydb/elements/details/samples/analysesTab/SampleDetailsContainersAux.spec.js
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import Enzyme, { mount, shallow } from 'enzyme'; | ||
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; | ||
import { | ||
describe, it, beforeEach | ||
} from 'mocha'; | ||
|
||
import { | ||
HeaderDeleted, HeaderNormal | ||
} from 'src/apps/mydb/elements/details/samples/analysesTab/SampleDetailsContainersAux'; | ||
|
||
import Container from 'src/models/Container'; | ||
import Sample from 'src/models/Sample'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('SampleDetailsContainersAux', () => { | ||
describe('HeaderDeleted', () => { | ||
describe('Render without edit mode', () => { | ||
let container; | ||
beforeEach(() => { | ||
container = Container.buildEmpty(); | ||
container.name = 'Just a string'; | ||
}); | ||
|
||
it('Render without kind and status', () => { | ||
const wrapper = shallow(<HeaderDeleted container={container} />); | ||
expect(wrapper.html()) | ||
.toEqual(`<div class="analysis-header-delete"><strike>${container.name}</strike><div class="button-right undo-middle"></div></div>`); | ||
}); | ||
|
||
it('Render with kind', () => { | ||
container.extended_metadata.kind = 'Just a kind string'; | ||
const wrapper = shallow(<HeaderDeleted container={container} />); | ||
expect(wrapper.html()) | ||
.toEqual(`<div class="analysis-header-delete"><strike>${container.name} - Type: ${container.extended_metadata.kind}</strike><div class="button-right undo-middle"></div></div>`); | ||
}); | ||
|
||
it('Render with status', () => { | ||
container.extended_metadata.status = 'Just a status string'; | ||
const wrapper = shallow(<HeaderDeleted container={container} />); | ||
expect(wrapper.html()) | ||
.toEqual(`<div class="analysis-header-delete"><strike>${container.name} - Status: ${container.extended_metadata.status}</strike><div class="button-right undo-middle"></div></div>`); | ||
}); | ||
|
||
it('Render with kind and status', () => { | ||
container.extended_metadata.kind = 'Just a kind string'; | ||
container.extended_metadata.status = 'Just a status string'; | ||
const wrapper = shallow(<HeaderDeleted container={container} />); | ||
expect(wrapper.html()) | ||
.toEqual(`<div class="analysis-header-delete"><strike>${container.name} - Type: ${container.extended_metadata.kind} - Status: ${container.extended_metadata.status}</strike><div class="button-right undo-middle"></div></div>`); | ||
}); | ||
}); | ||
|
||
describe('Render with edit mode', () => { | ||
const container = Container.buildEmpty(); | ||
container.name = 'Just a string'; | ||
|
||
it('Render without kind and status', () => { | ||
const wrapper = shallow(<HeaderDeleted container={container} mode="edit" />); | ||
expect(wrapper.html()) | ||
.toEqual(`<div class="analysis-header-delete"><strike>${container.name}</strike><div class="button-right undo-middle"><button type="button" class="pull-right btn btn-xs btn-danger"><i class="fa fa-undo"></i></button></div></div>`); | ||
}); | ||
|
||
it('Check on click instance', () => { | ||
const testOnClick = () => {}; | ||
const wrapper = mount(<HeaderDeleted container={container} mode="edit" handleUndo={testOnClick} />); | ||
const button = wrapper.find('button'); | ||
const onClickProp = button.prop('onClick'); | ||
expect(onClickProp).toBeInstanceOf(Function); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('HeaderNormal', () => { | ||
describe('Render without edit mode', () => { | ||
let container; let | ||
sample; | ||
|
||
beforeEach(() => { | ||
container = Container.buildEmpty(); | ||
container.name = 'Just a string'; | ||
sample = Sample.buildEmpty(); | ||
}); | ||
|
||
it('Render without status', () => { | ||
const wrapper = shallow(<HeaderNormal container={container} sample={sample} />); | ||
const statusWrapper = shallow(<div className="sub-title"> | ||
Status: | ||
{' '} | ||
{container.extended_metadata.status} | ||
{' '} | ||
|
||
{' '} | ||
| ||
{' '} | ||
|
||
</div>); | ||
expect(wrapper.html()) | ||
.toEqual(`<div class="analysis-header order"><div class="preview"><div class="preview-table"><img src="/images/wild_card/no_attachment.svg" alt="" style="cursor:default"/></div></div><div class="abstract"><div class="lower-text"><div class="main-title">${container.name}</div><div class="sub-title">Type: </div>${statusWrapper.html()}<div class="desc sub-title"><span style="float:left;margin-right:5px">Content:</span><span></span></div></div></div></div>`); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.