import * as Cookie from 'js-cookie';
import { defaultLanguage } from './stepDefaults';

describe('stepDefaults', () => {
  beforeEach(() => {
    Cookie.remove('readme_language');
  });

  it('should build a language selection using user cookie', () => {
    Cookie.set('readme_language', 'c');

    const defLang = defaultLanguage();
    expect(defLang).toStrictEqual({
      code: '',
      language: 'c',
      highlightedSyntax: 'text/x-csrc',
      name: 'C',
    });
  });

  it('should return a default if incorrect cookie set', () => {
    Cookie.set('readme_language', 'asdasdf');

    const defLang = defaultLanguage();
    expect(defLang).toStrictEqual({
      code: '',
      language: 'c',
      highlightedSyntax: 'text/x-csrc',
      name: 'C',
    });
  });

  it('should return a default if no cookie exists', () => {
    const defLang = defaultLanguage();
    expect(defLang).toStrictEqual({
      code: '',
      language: 'c',
      highlightedSyntax: 'text/x-csrc',
      name: 'C',
    });
  });
});
