<commit_before>const path = require('path');
const SelectListView = require('atom-select-list');

describe('GrammarSelector', () => {
  let [editor, textGrammar, jsGrammar] = [];

  beforeEach(async () => {
    jasmine.attachToDOM(atom.views.getView(atom.workspace));
    atom.config.set('grammar-selector.showOnRightSideOfStatusBar', false);
    atom.config.set('grammar-selector.hideDuplicateTextMateGrammars', false);

    await atom.packages.activatePackage('status-bar');
    await atom.packages.activatePackage('grammar-selector');
    await atom.packages.activatePackage('language-text');
    await atom.packages.activatePackage('language-javascript');
    await atom.packages.activatePackage(
      path.join(__dirname, 'fixtures', 'language-with-no-name')
    );

    editor = await atom.workspace.open('sample.js');

    textGrammar = atom.grammars.grammarForScopeName('text.plain');
    expect(textGrammar).toBeTruthy();
    jsGrammar = atom.grammars.grammarForScopeName('source.js');
    expect(jsGrammar).toBeTruthy();
    expect(editor.getGrammar()).toBe(jsGrammar);
  });

  describe('when grammar-selector:show is triggered', () =>
    it('displays a list of all the available grammars', async () => {
      const grammarView = (await getGrammarView(editor)).element;

      // -1 for removing nullGrammar, +1 for adding "Auto Detect"
      // Tree-sitter names the regex and JSDoc grammars
      expect(grammarView.querySelectorAll('li').length).toBe(
        atom.grammars.grammars.filter(g => g.name).length
      );
      expect(grammarView.querySelectorAll('li')[0].textContent).toBe(
        'Auto Detect'
      );
      expect(grammarView.textContent.includes('source.a')).toBe(false);
      grammarView
        .querySelectorAll('li')<commit_msg>fix spec<commit_after>const path = require('path');
const SelectListView = require('atom-select-list');

describe('GrammarSelector', () => {
  let [editor, textGrammar, jsGrammar] = [];

  beforeEach(async () => {
    jasmine.attachToDOM(atom.views.getView(atom.workspace));
    atom.config.set('grammar-selector.showOnRightSideOfStatusBar', false);
    atom.config.set('grammar-selector.hideDuplicateTextMateGrammars', false);

    await atom.packages.activatePackage('status-bar');
    await atom.packages.activatePackage('grammar-selector');
    await atom.packages.activatePackage('language-text');
    await atom.packages.activatePackage('language-javascript');
    await atom.packages.activatePackage(
      path.join(__dirname, 'fixtures', 'language-with-no-name')
    );

    editor = await atom.workspace.open('sample.js');

    textGrammar = atom.grammars.grammarForScopeName('text.plain');
    expect(textGrammar).toBeTruthy();
    jsGrammar = atom.grammars.grammarForScopeName('source.js');
    expect(jsGrammar).toBeTruthy();
    expect(editor.getGrammar()).toBe(jsGrammar);
  });

  describe('when grammar-selector:show is triggered', () =>
    it('displays a list of all the available grammars', async () => {
      const grammarView = (await getGrammarView(editor)).element;

      // -1 for removing nullGrammar, +1 for adding "Auto Detect"
      // Tree-sitter names the regex and JSDoc grammars
      expect(grammarView.querySelectorAll('li').length).toBe(
        atom.grammars
          .getGrammars({ includeTreeSitter: true })
          .filter(g => g.name).length
      );
      expect(grammarView.querySelectorAll('li')[0].textContent).toBe(
        'Auto Detect'
      );
      expect(grammarView.textContent.includes('source.a')).toBe(false);
      grammarView
        .querySelectorAll('li')
{'fraction_non_alphanumeric': 0.14628030091947616, 'fraction_numerical': 0.0016717748676511562, 'mean_word_length': 4.092198581560283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736546', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1103, 'n_words': 168}