import {mountWithTheme} from 'sentry-test/enzyme';
import DateTime from 'app/components/dateTime';
import ConfigStore from 'app/stores/configStore';
describe('DateTime', () => {
const user = {
...TestStubs.User(),
options: {
clock24Hours: false,
timezone: 'America/Los_Angeles',
},
};
beforeAll(() => {
ConfigStore.loadInitialData({user});
});
it('renders a date', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('Oct 16, 2017 7:41:20 PM PDT');
});
it('renders a date without seconds', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('Oct 16, 2017 7:41 PM');
});
it('renders timeonly', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('7:41 PM');
});
it('renders dateOnly', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('October 16, 2017');
});
it('renders shortDate', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('10/16/2017');
});
it('renders timeAndDate', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('Oct 16, 7:41 PM');
});
it('renders date with forced utc', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('Oct 17, 2017 2:41:20 AM UTC');
});
describe('24 Hours', () => {
beforeAll(() => {
user.options.clock24Hours = true;
ConfigStore.set('user', user);
});
afterAll(() => {
user.options.clock24Hours = false;
ConfigStore.set('user', user);
});
it('renders a date', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('Oct 16, 2017 19:41');
});
it('renders timeonly', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('19:41');
});
it('renders timeAndDate', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('Oct 16, 19:41');
});
it('renders date with forced utc', () => {
const wrapper = mountWithTheme();
expect(wrapper.text()).toBe('Oct 17, 2017 02:41');
});
});
});