Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* global describe, it, expect */
const fs = require("fs");
const path = require("path");
const rmfr = require("rmfr");
const configuration = require("@swissquote/crafty/src/configuration");
const testUtils = require("../utils");
// Add a high timeout because of https://github.com/facebook/jest/issues/8942
// Tests would be unreliable if they timeout >_<
jest.setTimeout(30000);
const getCrafty = configuration.getCrafty;
it("Loads crafty-preset-images-simple and does not register gulp tasks", () => {
const crafty = getCrafty(["@swissquote/crafty-preset-images-simple"], {});
const loadedPresets = crafty.config.loadedPresets.map(
preset => preset.presetName
);
expect(loadedPresets).toContain("@swissquote/crafty-preset-images-simple");
crafty.createTasks();
expect(Object.keys(crafty.undertaker._registry.tasks())).toEqual([]);
});
it("Fails if both crafty-preset-images-simple and crafty-preset-images-simple are loaded", () => {
const crafty = getCrafty(
[
/* global describe, it, expect */
const path = require("path");
const configuration = require("@swissquote/crafty/src/configuration");
const { run, cleanDist, exists, readFile } = require("../utils");
const getCrafty = configuration.getCrafty;
jest.setTimeout(10000);
it("Loads crafty-preset-typescript and does not register gulp tasks", () => {
const crafty = getCrafty(["@swissquote/crafty-preset-typescript"], {});
const loadedPresets = crafty.config.loadedPresets.map(
preset => preset.presetName
);
expect(loadedPresets).toContain("@swissquote/crafty-preset-typescript");
crafty.createTasks();
expect(Object.keys(crafty.undertaker._registry.tasks())).toEqual([]);
});
it("Loads crafty-preset-typescript, crafty-runner-gulp and registers gulp task", () => {
/* global describe, it, expect */
const path = require("path");
const configuration = require("@swissquote/crafty/src/configuration");
const getCommands = require("@swissquote/crafty/src/commands/index");
const { run, cleanDist, exists, readFile } = require("../utils");
jest.setTimeout(10000);
const getCrafty = configuration.getCrafty;
it("Loads crafty-preset-babel and does not register gulp tasks", () => {
const crafty = getCrafty(["@swissquote/crafty-preset-babel"], {});
const loadedPresets = crafty.config.loadedPresets.map(
preset => preset.presetName
);
expect(loadedPresets).toContain("@swissquote/crafty-preset-babel");
const commands = getCommands(crafty);
expect(Object.keys(commands)).toContain("jsLint");
crafty.createTasks();
expect(Object.keys(crafty.undertaker._registry.tasks())).toEqual([]);
});
/* global describe, it, expect */
const fs = require("fs");
const path = require("path");
const rmfr = require("rmfr");
const configuration = require("@swissquote/crafty/src/configuration");
const testUtils = require("../utils");
// Add a high timeout because of https://github.com/facebook/jest/issues/8942
// Tests would be unreliable if they timeout >_<
jest.setTimeout(30000);
const getCrafty = configuration.getCrafty;
it("Loads crafty-preset-images and does not register gulp tasks", () => {
const crafty = getCrafty(["@swissquote/crafty-preset-images"], {});
const loadedPresets = crafty.config.loadedPresets.map(
preset => preset.presetName
);
expect(loadedPresets).toContain("@swissquote/crafty-preset-images");
crafty.createTasks();
expect(Object.keys(crafty.undertaker._registry.tasks())).toEqual([]);
});
it("Loads crafty-preset-images, crafty-runner-gulp and registers gulp task", () => {
const crafty = getCrafty(
["@swissquote/crafty-preset-images", "@swissquote/crafty-runner-gulp"],
/* global describe, it, expect, jest */
const path = require("path");
const configuration = require("@swissquote/crafty/src/configuration");
const getCommands = require("@swissquote/crafty/src/commands/index");
const {
run,
cleanDist,
exists,
readFile,
snapshotizeOutput
} = require("../utils");
const getCrafty = configuration.getCrafty;
// node-forge 0.6.33 doesn't work with jest.
// but selfsigned is fixed on this version
// as we don't use it for now, we can simply mock it
// https://github.com/jfromaniello/selfsigned/issues/16
jest.mock("node-forge");
const PRESET_BABEL = "@swissquote/crafty-preset-babel";
jest.setTimeout(10000);
it("Loads crafty-preset-babel and does not register webpack tasks", () => {
const crafty = getCrafty([PRESET_BABEL], {});
const loadedPresets = crafty.config.loadedPresets.map(
preset => preset.presetName
/* global describe, it, expect */
const path = require("path");
const configuration = require("@swissquote/crafty/src/configuration");
const getCommands = require("@swissquote/crafty/src/commands/index");
const {
run,
cleanDist,
exists,
readFile,
snapshotizeOutput
} = require("../utils");
const getCrafty = configuration.getCrafty;
jest.setTimeout(10000);
it("Loads crafty-preset-postcss and does not register gulp tasks", () => {
const crafty = getCrafty(["@swissquote/crafty-preset-postcss"], {});
const loadedPresets = crafty.config.loadedPresets.map(
preset => preset.presetName
);
expect(loadedPresets).toContain("@swissquote/crafty-preset-postcss");
const commands = getCommands(crafty);
expect(Object.keys(commands)).toContain("cssLint");
crafty.createTasks();
expect(Object.keys(crafty.undertaker._registry.tasks())).toEqual([]);
/* global describe, it, expect */
const path = require("path");
const rmfr = require("rmfr");
const configuration = require("@swissquote/crafty/src/configuration");
const getCommands = require("@swissquote/crafty/src/commands/index");
const testUtils = require("../utils");
// Add a high timeout because of https://github.com/facebook/jest/issues/8942
// Tests would be unreliable if they timeout >_<
jest.setTimeout(30000);
const getCrafty = configuration.getCrafty;
it("Loads crafty-preset-postcss, crafty-runner-gulp and registers gulp task", () => {
const config = { myBundle: { source: "css/style.scss" } };
const crafty = getCrafty(
["@swissquote/crafty-preset-postcss", "@swissquote/crafty-runner-gulp"],
config
);
const loadedPresets = crafty.config.loadedPresets.map(
preset => preset.presetName
);
expect(loadedPresets).toContain("@swissquote/crafty-preset-postcss");
expect(loadedPresets).toContain("@swissquote/crafty-runner-gulp");
const commands = getCommands(crafty);
expect(Object.keys(commands)).toContain("cssLint");
/* global describe, it, expect, jest */
const fs = require("fs");
const path = require("path");
const rmfr = require("rmfr");
const configuration = require("@swissquote/crafty/src/configuration");
const testUtils = require("../utils");
const getCrafty = configuration.getCrafty;
// Add a high timeout because of https://github.com/facebook/jest/issues/8942
// Tests would be unreliable if they timeout >_<
jest.setTimeout(30000);
// node-forge 0.6.33 doesn't work with jest.
// but selfsigned is fixed on this version
// as we don't use it for now, we can simply mock it
// https://github.com/jfromaniello/selfsigned/issues/16
jest.mock("node-forge");
it("Loads crafty-preset-typescript and does not register webpack tasks", () => {
const crafty = getCrafty(["@swissquote/crafty-preset-typescript"], {});
const loadedPresets = crafty.config.loadedPresets.map(
preset => preset.presetName