Skip to content

Commit

Permalink
add failing test for table-of-contents plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Jul 23, 2019
1 parent 0dcbff2 commit c5d9198
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions test/plugins/table-of-contents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* eslint-disable no-useless-escape */

const { createBuilder, createTempDir } = require('broccoli-test-helper');
const { expect } = require('chai');
const TableOfContents = require('../../lib/table-of-contents');

describe('table-of-contents', function () {
it('should build', async function () {
const input = await createTempDir();
try {
// TODO why does this need to be an array of folders
const subject = new TableOfContents([input.path()]);
const output = createBuilder(subject);

try {
// INITIAL
input.write({
'pages.yml': `- title: "Getting Started"
url: 'getting-started'
pages:
- title: "How To Use The Guides"
url: "intro"`,
});

await output.build();

expect(output.read()).to.deep.equal({
'pages.json': '{"data":[{"type":"pages","id":"getting-started","attributes":{"title":"Getting Started","pages":[{"title":"How To Use The Guides","url":"getting-started/intro"}]}}]}',
});

expect(output.changes()).to.deep.equal({
'pages.json': 'create',
});

// UPDATE
input.write({
'pages.yml': `- title: "Tutorial"
url: 'tutorial'
pages:
- title: "Creating Your App"
url: "ember-cli"`, // change
});
await output.build();

expect(output.read()).to.deep.equal({
'pages.json': '{"data":[{"type":"pages","id":"tutorial","attributes":{"title":"Tutorial","pages":[{"title":"Creating Your App","url":"tutorial/ember-cli"}]}}]}',
});

expect(output.changes()).to.deep.equal({
'pages.json': 'change',
});

// NOOP
await output.build();

expect(output.changes()).to.deep.equal({});
} finally {
await output.dispose();
}
} finally {
await input.dispose();
}
});
});

0 comments on commit c5d9198

Please sign in to comment.