import ConfigStore from 'sentry/stores/configStore';

describe('ConfigStore', () => {
  it('should have apiUrl and organizationUrl', () => {
    const links = ConfigStore.get('links');
    expect(links).toEqual({
      organizationUrl: 'https://foobar.sentry.io',
      regionUrl: 'https://us.sentry.io',
      sentryUrl: 'https://sentry.io',
    });
  });

  it('should have cookie names', () => {
    const csrfCookieName = ConfigStore.get('csrfCookieName');
    expect(csrfCookieName).toEqual('csrf-test-cookie');

    const superUserCookieName = ConfigStore.get('superUserCookieName');
    expect(superUserCookieName).toEqual('su-test-cookie');
  });

  it('should have customerDomain', () => {
    const customerDomain = ConfigStore.get('customerDomain');
    expect(customerDomain).toEqual({
      subdomain: 'foobar',
      organizationUrl: 'https://foobar.sentry.io',
      sentryUrl: 'https://sentry.io',
    });
  });

  it('returns a stable reference from getState()', () => {
    ConfigStore.set('theme', 'dark');
    const state = ConfigStore.getState();
    expect(Object.is(state, ConfigStore.getState())).toBe(true);
  });
});
