<commit_before>Base = require '../lib/base'

describe "command-table", ->
  beforeEach ->
    waitsForPromise ->
      atom.packages.activatePackage('vim-mode-plus')

  describe "initial classRegistry", ->
    it "contains one entry and it's Base class", ->
      classRegistry = Base.getClassRegistry()
      keys = Object.keys(classRegistry)
      expect(keys).toHaveLength(1)
      expect(keys[0]).toBe("Base")
      expect(classRegistry[keys[0]]).toBe(Base)

  describe "fully populated classRegistry", ->
    it "generateCommandTableByEagerLoad populate all registry eagerly", ->
      oldRegistries = Base.getClassRegistry()
      oldRegistriesLength = Object.keys(oldRegistries).length
      expect(Object.keys(oldRegistries)).toHaveLength(1)

      Base.generateCommandTableByEagerLoad()
      newRegistriesLength = Object.keys(Base.getClassRegistry()).length
      expect(newRegistriesLength).toBeGreaterThan(oldRegistriesLength)

  describe "make sure cmd-table is NOT out-of-date", ->
    it "generateCommandTableByEagerLoad return table which is equals to initially loaded command table", ->
      [oldCommandTable, newCommandTable] = []

      oldCommandTable = Base.commandTable
      newCommandTable = Base.generateCommandTableByEagerLoad()
      loadedCommandTable = require('../lib/command-table')

      expect(oldCommandTable).not.toBe(newCommandTable)
      expect(loadedCommandTable).toEqual(oldCommandTable)
      expect(loadedCommandTable).toEqual(newCommandTable)<commit_msg>don't access lib for this spec file. and move under more big category<commit_after>
describe "dirty work for fast package activation", ->
  [main] = []
  beforeEach ->
    waitsForPromise ->
      atom.packages.activatePackage('vim-mode-plus').then (pack) ->
        main = pack.mainModule

  describe "requrie as minimum num of file as possible on startup", ->
    # * To reduce IO and compile-evaluation of js file on startup
    describe "with no editor opened", ->
    beforeEach ->
      waitsForPromise ->
        atom.packages.activatePackage('vim-mode-plus')

  fdescribe "command-table", ->
    # * Loading atom commands from pre-generated command-table.
    # * Why?
    #  vmp adds about 300 cmds, which is huge, dynamically calculating and register cmds
    #  took very long time.
    #  So calcluate non-dynamic par then save to command-table.coffe and load in on startup.
    #  When command are executed, necessary command class file is lazy-required.
    beforeEach ->
      waitsForPromise ->
        atom.packages.activatePackage('vim-mode-plus').then (pack) ->
          main = pack.mainModule

    describe "initial classRegistry", ->
      it "contains one entry and it's Base class", ->
        Base = main.provideVimModePlus().Base
        classRegistry = Base.getClassRegistry()
        keys = Object.keys(classRegistry)
        expect(keys).toHaveLength(1)
        expect(keys[0]).toBe("Base")
        expect(classRegistry[keys[0]]).toBe(Base)

    describe "fully populated classRegistry", ->
      it "generateCommandTableByEagerLoad populate all registry eagerly", ->
        Base = main.provideVimModePlus().Base
        oldRegistries = Base.getClassRegistry()
        oldRegistriesLength = Object.keys(oldRegistries).length
        expect(Object.keys(oldRegistries)).toHaveLength(1)

        Base.generateCommandTableByEagerLoad()
        newRegistriesLength = Object.keys(Base.getClassRegistry()).length
        expect(newRegistriesLength).toBeGreaterThan(oldRegistriesLength)

    describe "make sure cmd-table is NOT out-of-date", ->
      it "generateCommandTableByEagerLoad return table which is equals to initially loaded command table", ->
        Base = main.provideVimModePlus().Base
        [oldCommandTable, newCommandTable] = []

        oldCommandTable = Base.commandTable
        newCommandTable = Base.generateCommandTableByEagerLoad()
        loadedCommandTable = require('../lib/command-table')

        expect(oldCommandTable).not.toBe(newCommandTable)
        expect(loadedCommandTable).toEqual(oldCommandTable)
        expect(loadedCommandTable).toEqual(newCommandTable)
{'fraction_non_alphanumeric': 0.10218446601941747, 'fraction_numerical': 0.002669902912621359, 'mean_word_length': 3.5236004390779363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '6322994', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1099, 'n_words': 258}