"use strict";

var runMochaJSON = require("./helpers.cjs").runMochaJSON;

describe("when non-array argument is provided multiple times", function () {
  describe("when the same argument name is used", function () {
    it("should prefer the last value", function (done) {
      runMochaJSON(
        "passing-sync.fixture.js",
        ["--no-async-only", "--async-only", "--no-async-only"],
        function (err, result) {
          if (err) {
            return done(err);
          }
          expect(result, "to have passed");
          done();
        },
      );
    });
  });

  describe("when a different argument name is used", function () {
    it("should prefer the last value", function (done) {
      runMochaJSON(
        "passing-async.fixture.js",
        ["--timeout", "100", "-t", "10"],
        function (err, result) {
          if (err) {
            return done(err);
          }
          expect(result, "to have failed");
          done();
        },
      );
    });
  });
});
