verdnatura-chat/app/containers/UnreadBadge/getUnreadStyle.test.js

95 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

/* eslint-disable no-undef */
import { themes } from '../../lib/constants';
import { getUnreadStyle } from './getUnreadStyle';
const testsForTheme = theme => {
const getUnreadStyleUtil = ({ ...props }) => getUnreadStyle({ theme, ...props });
[NEW] Threads (#2567) * [IMPROVEMENT] Mentions layout without background * Fix RoomItem * Fix tests * Smaller messagebox * Messagebox colors tweak * Beginning header buttons refactor * Add HeaderButtons * item with title * Refactor * Remove lib * Refactor * Update snapshot * Send to channel on messagebox * Add tshow * Add showMessageInMainThread to login.user reducer * Filter threads on main channel based on user setting * Send tshow * Add tunread * Move unread colors logic away from UnreadBadge component so it can be used on other components * Export UnreadBadge on index * Add empty test * Refactor * Update tests * Lint * Thread unread user and group on RoomItem * Thread badge working * Started ThreadMessagesView.Item * Fix separator * Reactivity working * Lint * custom emojis aren't necessary * Basic filter layout * Filtering layout * Refactor * apply filter * DropdownItemHeader * default all * few fixes * No data found * Fixes list performance issues * Use locale on date formats * Fixed minor styles * Thread badge * Refactor getBadgeColor * Fix send to channel background color * starting search threads * Fix lint and tests * Bump to 4.12.0 just for testing :) * Search input layout * query * starting threads header * fix unnecessary tlm on tmid messages * Fix thread header * lint * Fix thread header on ShareView * Add e2e tests * Fix subscriptions sort * Update stories and minor fixes * Fix button sizes on Messagebox * Remove comment * Unnecessary conditional * Add showMessageInMainThread to user collection * Fix thread header * Fix thread messages not working on tablet * Reset Messagebox.tshow after sending a message * Allow to send to channel when replying to a thread from main channel * Unnecessary theme prop * Address comments * Remove re-render * Fix scroll indicator bug * Fix style * Minor i18n fix * Fix dropdown height * I18n ptbr * I18n
2020-10-30 17:35:07 +00:00
test('render empty', () => {
expect(getUnreadStyleUtil({})).toEqual({});
});
test('render unread', () => {
expect(
getUnreadStyleUtil({
unread: 1
})
).toEqual({
backgroundColor: themes[theme].unreadColor,
color: themes[theme].buttonText
});
});
test('render thread unread', () => {
expect(
getUnreadStyleUtil({
tunread: [1]
})
).toEqual({
backgroundColor: themes[theme].tunreadColor,
color: themes[theme].buttonText
});
});
test('render user mention', () => {
expect(
getUnreadStyleUtil({
unread: 1,
userMentions: 1
})
).toEqual({
backgroundColor: themes[theme].mentionMeColor,
color: themes[theme].buttonText
});
});
test('render group mention', () => {
expect(
getUnreadStyleUtil({
unread: 1,
groupMentions: 1
})
).toEqual({
backgroundColor: themes[theme].mentionGroupColor,
color: themes[theme].buttonText
});
});
test('mentions priority', () => {
expect(
getUnreadStyleUtil({
unread: 1,
userMentions: 1,
groupMentions: 1,
tunread: [1]
})
).toEqual({
backgroundColor: themes[theme].mentionMeColor,
color: themes[theme].buttonText
});
expect(
getUnreadStyleUtil({
unread: 1,
groupMentions: 1,
tunread: [1]
})
).toEqual({
backgroundColor: themes[theme].mentionGroupColor,
color: themes[theme].buttonText
});
expect(
getUnreadStyleUtil({
unread: 1,
tunread: [1]
})
).toEqual({
backgroundColor: themes[theme].tunreadColor,
color: themes[theme].buttonText
});
});
};
describe('getUnreadStyle light theme', () => testsForTheme('light'));
describe('getUnreadStyle dark theme', () => testsForTheme('dark'));
describe('getUnreadStyle black theme', () => testsForTheme('black'));