<commit_before>assert = require 'assert'
ipc    = require 'ipc'
path   = require 'path'
remote = require 'remote'

BrowserWindow = remote.require 'browser-window'

describe 'ipc module', ->
  fixtures = path.join __dirname, 'fixtures'

  describe 'remote.require', ->
    it 'should returns same object for the same module', ->
      dialog1 = remote.require 'dialog'
      dialog2 = remote.require 'dialog'
      assert.equal dialog1, dialog2

    it 'should work when object contains id property', ->
      a = remote.require path.join(fixtures, 'module', 'id.js')
      assert.equal a.id, 1127

  describe 'remote.createFunctionWithReturnValue', ->
    it 'should be called in browser synchronously', ->
      buf = new Buffer('test')
      call = remote.require path.join(fixtures, 'module', 'call.js')
      result = call.call remote.createFunctionWithReturnValue(buf)
      assert.equal result.constructor.name, 'Buffer'<commit_msg>Add spec for checking process.mainModule.<commit_after>assert = require 'assert'
ipc    = require 'ipc'
path   = require 'path'
remote = require 'remote'

BrowserWindow = remote.require 'browser-window'

describe 'ipc module', ->
  fixtures = path.join __dirname, 'fixtures'

  describe 'remote.require', ->
    it 'should returns same object for the same module', ->
      dialog1 = remote.require 'dialog'
      dialog2 = remote.require 'dialog'
      assert.equal dialog1, dialog2

    it 'should work when object contains id property', ->
      a = remote.require path.join(fixtures, 'module', 'id.js')
      assert.equal a.id, 1127

    it 'should search module from the user app', ->
      assert.equal remote.process.mainModule.filename, path.resolve(__dirname, 'static', 'main.js')
      assert.equal remote.process.mainModule.paths[0], path.resolve(__dirname, 'static', 'node_modules')

  describe 'remote.createFunctionWithReturnValue', ->
    it 'should be called in browser synchronously', ->
      buf = new Buffer('test')
      call = remote.require path.join(fixtures, 'module', 'call.js')
      result = call.call remote.createFunctionWithReturnValue(buf)
      assert.equal result.constructor.name, 'Buffer'
{'fraction_non_alphanumeric': 0.11933395004625347, 'fraction_numerical': 0.00786308973172988, 'mean_word_length': 3.611940298507463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '7625906', 'n_tokens_mistral': 624, 'n_tokens_neox': 608, 'n_words': 183}