-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add useAvatarForBot and useAvatarForUser (#2544)
- Loading branch information
Showing
9 changed files
with
122 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('getter should return image and initial of avatar for bot', async () => { | ||
const { pageObjects } = await setupWebDriver({ | ||
props: { | ||
styleOptions: { | ||
botAvatarImage: 'about:blank#bot-icon', | ||
botAvatarInitials: 'WC' | ||
} | ||
} | ||
}); | ||
|
||
const [{ image, initials }] = await pageObjects.runHook('useAvatarForBot'); | ||
|
||
expect({ image, initials }).toMatchInlineSnapshot(` | ||
Object { | ||
"image": "about:blank#bot-icon", | ||
"initials": "WC", | ||
} | ||
`); | ||
}); | ||
|
||
test('setter should throw exception', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
|
||
await expect(pageObjects.runHook('useAvatarForBot', [], result => result[1]())).rejects.toThrow(); | ||
}); |
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,32 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('getter should return image and initial of avatar for user', async () => { | ||
const { pageObjects } = await setupWebDriver({ | ||
props: { | ||
styleOptions: { | ||
userAvatarImage: 'about:blank#user-icon', | ||
userAvatarInitials: 'WW' | ||
} | ||
} | ||
}); | ||
|
||
const [{ image, initials }] = await pageObjects.runHook('useAvatarForUser'); | ||
|
||
expect({ image, initials }).toMatchInlineSnapshot(` | ||
Object { | ||
"image": "about:blank#user-icon", | ||
"initials": "WW", | ||
} | ||
`); | ||
}); | ||
|
||
test('setter should throw exception', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
|
||
await expect(pageObjects.runHook('useAvatarForUser', [], result => result[1]())).rejects.toThrow(); | ||
}); |
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,12 @@ | ||
import useStyleOptions from './useStyleOptions'; | ||
|
||
export default function useAvatarForBot() { | ||
const [{ botAvatarImage: image, botAvatarInitials: initials }] = useStyleOptions(); | ||
|
||
return [ | ||
{ | ||
image, | ||
initials | ||
} | ||
]; | ||
} |
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,12 @@ | ||
import useStyleOptions from './useStyleOptions'; | ||
|
||
export default function useAvatarForUser() { | ||
const [{ userAvatarImage: image, userAvatarInitials: initials }] = useStyleOptions(); | ||
|
||
return [ | ||
{ | ||
image, | ||
initials | ||
} | ||
]; | ||
} |