|
| 1 | +const chai = require("chai"), |
| 2 | + sinon = require("sinon"), |
| 3 | + chaiAsPromised = require("chai-as-promised"), |
| 4 | + rewire = require("rewire"); |
| 5 | + |
| 6 | +const logger = require("../../../../bin/helpers/logger").winstonLogger, |
| 7 | + testObjects = require("../../support/fixtures/testObjects"); |
| 8 | + |
| 9 | +const syncRunner = rewire("../../../../bin/helpers/syncRunner"); |
| 10 | + |
| 11 | +chai.use(chaiAsPromised); |
| 12 | +logger.transports["console.info"].silent = true; |
| 13 | + |
| 14 | +logBuildDetails = syncRunner.__get__("logBuildDetails"); |
| 15 | + |
| 16 | +describe("syncRunner", () => { |
| 17 | + var sandbox, winstonLoggerStub; |
| 18 | + |
| 19 | + beforeEach(() => { |
| 20 | + sandbox = sinon.createSandbox(); |
| 21 | + winstonLoggerStub = sinon.stub(logger, "log").callsFake(() => {}); |
| 22 | + }); |
| 23 | + |
| 24 | + afterEach(() => { |
| 25 | + sandbox.restore(); |
| 26 | + sinon.restore(); |
| 27 | + }); |
| 28 | + |
| 29 | + describe("logBuildDetails", () => { |
| 30 | + let buildDetails = { |
| 31 | + machines: 10, |
| 32 | + combinations: 5, |
| 33 | + dashboard_url: "random_url", |
| 34 | + }; |
| 35 | + |
| 36 | + it("parallels defined", () => { |
| 37 | + logBuildDetails(testObjects.sampleBsConfigWithParallels, buildDetails); |
| 38 | + |
| 39 | + sinon.assert.calledThrice(winstonLoggerStub); |
| 40 | + sinon.assert.calledWithMatch(winstonLoggerStub, 'info', `Browser Combinations: ${buildDetails.combinations}`); |
| 41 | + sinon.assert.calledWithMatch(winstonLoggerStub, 'info', `Run in parallel: enabled (attempting to run on ${buildDetails.machines} machines)`); |
| 42 | + sinon.assert.calledWithMatch(winstonLoggerStub, 'info', `BrowserStack Dashboard: ${buildDetails.dashboard_url}`); |
| 43 | + }); |
| 44 | + it("parallels not defined", () => { |
| 45 | + logBuildDetails(testObjects.sampleBsConfig, buildDetails); |
| 46 | + |
| 47 | + sinon.assert.calledThrice(winstonLoggerStub); |
| 48 | + sinon.assert.calledWithMatch(winstonLoggerStub, 'info', `Browser Combinations: ${buildDetails.combinations}`); |
| 49 | + sinon.assert.calledWithMatch(winstonLoggerStub, 'info', `Run in parallel: disabled`); |
| 50 | + sinon.assert.calledWithMatch(winstonLoggerStub, 'info', `BrowserStack Dashboard: ${buildDetails.dashboard_url}`); |
| 51 | + }); |
| 52 | + }); |
| 53 | +}); |
0 commit comments