import path from "path";

import webpack from "webpack";

describe("IgnoreOrder", () => {
  it("should emit warnings", (done) => {
    const casesDirectory = path.resolve(__dirname, "cases");
    const directoryForCase = path.resolve(casesDirectory, "ignoreOrderFalse");

    const webpackConfig = require(
      path.resolve(directoryForCase, "webpack.config.js"),
    );

    const compiler = webpack({
      ...webpackConfig,
      mode: "development",
      context: directoryForCase,
      cache: false,
    });
    compiler.run((err1, stats) => {
      expect(stats.hasWarnings()).toBe(true);
      done();
    });
  });

  it("should not emit warnings", (done) => {
    const casesDirectory = path.resolve(__dirname, "cases");
    const directoryForCase = path.resolve(casesDirectory, "ignoreOrder");

    const webpackConfig = require(
      path.resolve(directoryForCase, "webpack.config.js"),
    );

    const compiler = webpack({
      ...webpackConfig,
      mode: "development",
      context: directoryForCase,
      cache: false,
    });
    compiler.run((err1, stats) => {
      expect(stats.hasWarnings()).toBe(false);
      done();
    });
  });
});
