<commit_before>{WorkspaceView, EditorView} = require("atom")
FilesizeCalculator = require("../lib/filesize-calculator")
os = require("os")

#FilesizeCalculator instance
filesizeCalculator = null

describe "FilesizeCalculator", ->

  beforeEach ->
    atom.workspaceView = new WorkspaceView()
    atom.workspace = atom.workspaceView.model
    waitsForPromise ->
      atom.workspace.open("spec/fixtures/test.txt")
    filesizeCalculator = new FilesizeCalculator()

  #TODO: Test .getSize() effectively
  xdescribe "when calling .getSize()", ->
    it "should return the correct size in bytes", ->
      filesizeCalculator.getSize (size, err) ->
        expect(err).toEqual(null)
        expect(atom.workspace.getActivePaneItem()).toExist()
        expect(size).toEqual(5)

  describe "when calling .makeReadable()", ->
    describe "when size < 1024 bytes", ->
      it "should display results in bytes when with 1024 multiple value", ->
        filesizeCalculator.makeReadable 1023, null, (size, err) ->
          expect(err).toEqual(null)
          expect(size).toEqual("1023 bytes")
      it "should display resulsts in KB with 1000 multiple value", ->
        filesizeCalculator.setMultiple(1000)
        filesizeCalculator.makeReadable 1023, null, (size, err) ->
          expect(err).toEqual(null)
          expect(size).toEqual("1.02 KB")
    describe "when size < 1048576", ->
      it "should display results in KiB with 1024 multiple value", ->
        filesizeCalculator.makeReadable 1048000, null, (size, err) -><commit_msg>Add tests for 0 and 1 bytes filesize<commit_after>{WorkspaceView, EditorView} = require("atom")
FilesizeCalculator = require("../lib/filesize-calculator")
os = require("os")

#FilesizeCalculator instance
filesizeCalculator = null

describe "FilesizeCalculator", ->

  beforeEach ->
    atom.workspaceView = new WorkspaceView()
    atom.workspace = atom.workspaceView.model
    waitsForPromise ->
      atom.workspace.open("spec/fixtures/test.txt")
    filesizeCalculator = new FilesizeCalculator()

  #TODO: Test .getSize() effectively
  xdescribe "when calling .getSize()", ->
    it "should return the correct size in bytes", ->
      filesizeCalculator.getSize (size, err) ->
        expect(err).toEqual(null)
        expect(atom.workspace.getActivePaneItem()).toExist()
        expect(size).toEqual(5)

  describe "when calling .makeReadable()", ->

    describe "when size is 0", ->
      it "should return 0 bytes", ->
        filesizeCalculator.makeReadable 0, null, (size, err) ->
          expect(err).toEqual(null)
          expect(size).toEqual("0 bytes")

    describe "when size is 1", ->
      it "should return 1 byte", ->
        filesizeCalculator.makeReadable 1, null, (size, err) ->
          expect(err).toEqual(null)
          expect(size).toEqual("1 byte")

    describe "when size < 1024 bytes", ->
      it "should display results in bytes when with 1024 multiple value", ->
        filesizeCalculator.makeReadable 1023, null, (size, err) ->
          expect(err).toEqual(null)
          expect(size).toEqual("1023 bytes")
      it "should display resulsts in KB with 1000 multiple value", ->
        filesizeCalculator.setMultiple(1000)
        filesizeCalculator.makeReadable 1023, null, (size, err) ->
          expect(err).toEqual(null)
          expect(size).toEqual("1.02 KB")
    describe "when size < 1048576", ->
      it "should display results in KiB with 1024 multiple value", ->
        filesizeCalculator.makeReadable 1048000, null, (size, err) ->
{'fraction_non_alphanumeric': 0.12329545454545454, 'fraction_numerical': 0.03125, 'mean_word_length': 3.196662693682956, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, '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': '4994886', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1018, 'n_words': 267}