-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/Sitecore/jss into feature/51…
…3285
- Loading branch information
Showing
19 changed files
with
118 additions
and
42 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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* eslint-disable no-unused-expressions */ | ||
import { expect } from 'chai'; | ||
import { ComponentRendering } from '../../layout'; | ||
import { getFieldValue, getChildPlaceholder } from './utils'; | ||
|
||
describe('sitecore-jss layout utils', () => { | ||
describe('getFieldValue', () => { | ||
const fields = { | ||
crop: { | ||
value: 'rice', | ||
}, | ||
}; | ||
|
||
it('should read field from ComponentRendering type', () => { | ||
const componentRendering: ComponentRendering = { | ||
componentName: 'uTest', | ||
fields: fields, | ||
}; | ||
|
||
const result = getFieldValue(componentRendering, 'crop'); | ||
expect(result).to.be.equal('rice'); | ||
}); | ||
|
||
it('should read field from Fields type', () => { | ||
expect(getFieldValue(fields, 'crop')).to.be.equal('rice'); | ||
}); | ||
|
||
it('should return default value when field is not found', () => { | ||
const defaultYield = '1000 tn'; | ||
expect(getFieldValue(fields, 'yield', defaultYield)).to.be.equal(defaultYield); | ||
}); | ||
}); | ||
|
||
describe('getChildPlaceholder', () => { | ||
it('should return child placeholder', () => { | ||
const testRendering: ComponentRendering = { | ||
componentName: 'test', | ||
placeholders: { | ||
place: [ | ||
{ | ||
componentName: 'placed', | ||
}, | ||
], | ||
holder: [ | ||
{ | ||
componentName: 'held', | ||
}, | ||
], | ||
}, | ||
}; | ||
const result = getChildPlaceholder(testRendering, 'place'); | ||
expect(result.length).to.be.equal(1); | ||
expect((result[0] as ComponentRendering).componentName).to.be.equal('placed'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.