<commit_before>'use babel';

describe('rustsym', () => {

  beforeEach(() => waitsForPromise(() => atom.packages.activatePackage('rustsym')));

  describe('given a Rust source file is open', () => {

    beforeEach(() => waitsForPromise(() => atom.workspace.open('tmp.rs')));

    describe('when the manual file symbols command is used', () => {
      it('should show the file symbols search view', () => {
        let workspaceElement = atom.views.getView(atom.workspace);
        let textEditorElement = atom.views.getView(atom.workspace.getActiveTextEditor());
        jasmine.attachToDOM(textEditorElement);
        atom.commands.dispatch(textEditorElement, 'rustsym:toggle-file-symbols');
        expect(workspaceElement.querySelector('.rustsym')).toExist();
        let statusBarModeElement = workspaceElement.querySelector('.rustsym-status-bar__mode');
        expect(statusBarModeElement).toExist();
        expect(statusBarModeElement.innerText.indexOf('file')).not.toBe(-1, 'incorrect search mode');
      });
    });

    describe('when the manual project symbols command is used', () => {
      it('should show the project symbols search view', () => {
        let workspaceElement = atom.views.getView(atom.workspace);
        jasmine.attachToDOM(workspaceElement);
        atom.commands.dispatch(workspaceElement, 'rustsym:toggle-project-symbols');
        expect(workspaceElement.querySelector('.rustsym')).toExist();
        let statusBarModeElement = workspaceElement.querySelector('.rustsym-status-bar__mode');
        expect(statusBarModeElement).toExist();
        expect(statusBarModeElement.innerText.indexOf('project')).not.toBe(-1, 'incorrect search mode');
      });
    });

  });

});<commit_msg>Fix tests broken due to the new Etch-based UI for Atom<commit_after>/** @babel */

describe('rustsym', () => {

  beforeEach(async () => await atom.packages.activatePackage('rustsym'));

  describe('given a Rust source file is open', () => {

    beforeEach(async () => await atom.workspace.open('tmp.rs'));

    describe('when the manual file symbols command is used', async () => {
      it('should show the file symbols search view', async () => {
        let workspaceElement = atom.views.getView(atom.workspace);
        let textEditorElement = atom.views.getView(atom.workspace.getActiveTextEditor());
        jasmine.attachToDOM(textEditorElement);
        atom.commands.dispatch(textEditorElement, 'rustsym:toggle-file-symbols');
        expect(workspaceElement.querySelector('.rustsym')).toExist();
        let statusBarModeElement;
        await waitFor(() => {
          statusBarModeElement = workspaceElement.querySelector('.rustsym-status-bar__mode');
          return statusBarModeElement != null;
        });
        expect(statusBarModeElement).toExist();
        expect(statusBarModeElement.innerText.indexOf('file')).not.toBe(-1, 'incorrect search mode');
      });
    });

    describe('when the manual project symbols command is used', () => {
      it('should show the project symbols search view', async () => {
        let workspaceElement = atom.views.getView(atom.workspace);
        jasmine.attachToDOM(workspaceElement);
        atom.commands.dispatch(workspaceElement, 'rustsym:toggle-project-symbols');
        expect(workspaceElement.querySelector('.rustsym')).toExist();
        let statusBarModeElement;
        await waitFor(() => {
          statusBarModeElement = workspaceElement.querySelector('.rustsym-status-bar__mode');
          return statusBarModeElement != null;
        });
        expect(statusBarModeElement).toExist();
        expect(statusBarModeElement.innerText.indexOf('project')).not.toBe(-1, 'incorrect search mode');
      });
    });

  });

});

/**
 * Simple condition polling helper to support tests involving VDOM behaviour.
 */
function waitFor(condition, timeout) {
  if (typeof timeout === 'undefined') timeout = 3000;
  const startTime = Date.now();
  const checkCondition = (resolve, reject) => {
    if (Date.now() - startTime > timeout) return reject();
    if (condition()) return resolve();
    setTimeout(checkCondition, 100, resolve, reject);
  };
  return new Promise(checkCondition);
}
{'fraction_non_alphanumeric': 0.14367678699497968, 'fraction_numerical': 0.002629691608893139, 'mean_word_length': 3.765375854214123, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '1256975', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1117, 'n_words': 226}