github.com/getgauge/gauge@v1.6.9/build/npm/test/test.js (about)

     1  "use strict"
     2  
     3  const expect = require('chai').expect,
     4      fs = require('fs'),
     5      sinon = require('sinon');
     6  
     7  var subject = require("../src/install");
     8  
     9  describe("getVersion", () => {
    10      it("should get the version in package.json", async () => {
    11          const dummyPath = "/foo/bar";
    12          sinon.stub(fs, "existsSync").returns(true);
    13          sinon.stub(fs, "readFile").withArgs(dummyPath).yields(undefined, '{"version": "x.y.z"}');
    14          
    15          expect(await subject.getVersion(dummyPath)).equal("x.y.z");
    16      });
    17  });
    18  
    19  describe("getBinaryUrl", () => {
    20      it("should return platform specific URL", async () => {
    21          let originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform');;
    22          let originalArch = Object.getOwnPropertyDescriptor(process, 'arch');;
    23          Object.defineProperty(process, 'platform', { value: "win32" });
    24          Object.defineProperty(process, 'arch', { value: "ia32" });
    25  
    26          expect(await subject.getBinaryUrl("1.0.0")).equals("https://github.com/getgauge/gauge/releases/download/v1.0.0/gauge-1.0.0-windows.x86.zip");
    27  
    28          Object.defineProperty(process, 'platform', originalPlatform);
    29          Object.defineProperty(process, 'arch', originalArch);
    30      });
    31  
    32  });
    33  
    34