JSPM

broccoli-test-helper

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8674
  • Score
    100M100P100Q137103F
  • License MIT

Test helpers for BroccoliPlugins that make testing build and rebuild behavior dead simple and expect diff friendly.

Package Exports

  • broccoli-test-helper

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (broccoli-test-helper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

broccoli-test-helper

Build status Build Status

Test helpers for BroccoliPlugins that make testing build and rebuild behavior dead simple and expect diff friendly.

'use strict';

const expect = require('chai').expect;
const helpers = require('broccoli-test-helper');
const createBuilder = helpers.createBuilder;
const createTempDir = helpers.createTempDir;
const MyBroccoliPlugin = require("../index");
const co = require('co');

describe("MyBroccoliPlugin", function() {
  let input;
  let output;
  let subject;

  beforeEach(co.wrap(function* () {
    input = yield createTempDir();
    subject = new MyBroccoliPlugin(input.path());
    output = createBuilder(subject);
  }));

  afterEach(co.wrap(function* () {
    yield input.dispose();
    yield output.dispose();
  }));

  it("should build", co.wrap(function* () {
    input.write({
      "index.js": `export { A } from "./lib/a";`,
      "lib": {
        "a.js": `export class A {};`,
        "b.js": `export class B {};`,
        "c.js": `export class C {};`
      }
    });

    yield output.build();

    expect(
      output.read()
    ).to.deep.equal({
      "index.js": `exports.A = require("./lib/a").A;`,
      "lib": {
        "a.js": `exports.A = class A {};`,
        "b.js": `exports.B = class B {};`,
        "c.js": `exports.C = class C {};`
      }
    });

    yield output.build();

    expect(
      output.changes()
    ).to.deep.equal({ });

    input.write({
      "index.js": "export class A {};",
      "lib": null // delete dir
    });

    yield output.build();

    expect(
      output.changes()
    ).to.deep.equal({
      "lib/c.js": "unlink",
      "lib/b.js": "unlink",
      "lib/a.js": "unlink",
      "lib/":     "rmdir",
      "index.js": "change"
    });

    expect(
      output.read()
    ).to.deep.equal({
      "index.js": `exports.A = class A {};`
    });
  }));
});