Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

1.2 KB
Raw Blame
"use strict";

var { expect } = require("chai");
const {
  types,
  expectedTypeForFlag,
  getRunOptionDefinitions,
} = require("../../../lib/cli/run-option-metadata.cjs");

describe("mocha-flags", function () {
  describe("expectedTypeForFlag()", function () {
    Object.entries(types).forEach(([dataType, flags]) => {
      flags.forEach((flag) => {
        it(`returns expected ${flag}'s type as ${dataType}`, function () {
          expect(expectedTypeForFlag(flag)).to.equal(dataType);
        });
      });
    });

    it("returns undefined for node flags", function () {
      expect(expectedTypeForFlag("--throw-deprecation")).to.equal(undefined);
      expect(expectedTypeForFlag("throw-deprecation")).to.equal(undefined);
    });

    it("returns undefined for unsupported flags", function () {
      expect(expectedTypeForFlag("--foo")).to.equal(undefined);
    });
  });

  describe("getRunOptionDefinitions()", function () {
    getRunOptionDefinitions()
      .filter((option) => option.name !== "spec")
      .forEach((option) => {
        it(`gives ${option.name} a description`, function () {
          expect(option.description).to.be.a("string").that.is.not.empty;
        });
      });
  });
});