{"size": 1170, "ext": "js", "max_stars_repo_path": "test_apps/test_app/test/embarkJS_spec.js", "max_stars_repo_name": "samthomson/embark", "max_stars_repo_stars_event_min_datetime": "2020-01-27T17:19:27.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-27T17:19:27.000Z", "max_issues_repo_path": "test_apps/test_app/test/embarkJS_spec.js", "max_issues_repo_name": "samthomson/embark", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test_apps/test_app/test/embarkJS_spec.js", "max_forks_repo_name": "samthomson/embark", "max_forks_repo_forks_event_min_datetime": "2021-02-27T10:16:06.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-27T10:16:06.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 32.5, "max_line_length": 150, "alphanum_fraction": 0.7068376068}
/*global describe, it, web3, config*/
const assert = require('assert');
const SimpleStorage = require('Embark/contracts/SimpleStorage');
const EmbarkJS = require('Embark/EmbarkJS');

config({
  contracts: {
    "SimpleStorage": {
      args: [100]
    }
  }
});

describe("EmbarkJS functions", function() {
  it('should have access to ENS functions', async function() {
    const rootAddress = await EmbarkJS.Names.resolve('embark.eth');
    assert.strictEqual(rootAddress, web3.eth.defaultAccount);

    const rootName = await EmbarkJS.Names.lookup(rootAddress);
    assert.strictEqual(rootName, 'embark.eth');
  });

  it('should have access to Storage functions', async function() {
    // Not calling the functions because it requires Swarm
    assert.ok(EmbarkJS.Storage.saveText);
    assert.ok(EmbarkJS.Storage.get);
  });

  it('should have access to Blockchain functions', async function() {
    const contract = new EmbarkJS.Blockchain.Contract({abi: SimpleStorage.options.jsonInterface, address: SimpleStorage.options.address, web3: web3});
    const result = await contract.methods.get().call();
    assert.strictEqual(parseInt(result, 10), 100);
  });
});

