Skip to content

Commit

Permalink
- modified tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ognian committed Mar 1, 2017
1 parent fcd5eed commit 532fb02
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions test/metadata.test.js
Expand Up @@ -36,16 +36,34 @@ const globalConfig = {
},
};

test.serial("should pass metadata code snippet", (t) => {
const config = assign({}, globalConfig, {});
// Create a separate directory for each test so that the tests
// can run in parallel
test.cb.beforeEach((t) => {
createTestDirectory(outputDir, t.title, (err, directory) => {
if (err) return t.end(err);
t.context.directory = directory;
t.end();
});
});

test.cb.afterEach((t) => rimraf(t.context.directory, t.end));


test.cb("should pass metadata code snippet", (t) => {
const config = assign({}, globalConfig, {
output: {
path: t.context.directory,
filename: "[id].metadata.js",
},
});

webpack(config, (err) => {
t.is(err, null);

fs.readdir(outputDir, (err, files) => {
fs.readdir(t.context.directory, (err, files) => {
t.is(err, null);
t.true(files.length > 0);
fs.readFile(path.resolve(outputDir, "reactIntlMessages.json"),
fs.readFile(path.resolve(t.context.directory, "reactIntlMessages.json"),
function(err, data) {
t.is(err, null);
const text = data.toString();
Expand All @@ -59,8 +77,13 @@ test.serial("should pass metadata code snippet", (t) => {
});
});

test.serial("should not throw error", (t) => {
const config = assign({}, globalConfig, {});
test.cb("should not throw error", (t) => {
const config = assign({}, globalConfig, {
output: {
path: t.context.directory,
filename: "[id].metadata.js",
},
});

webpack(config, (err, stats) => {
t.is(err, null);
Expand All @@ -69,8 +92,12 @@ test.serial("should not throw error", (t) => {
});
});

test.serial("should throw error", (t) => {
test.cb("should throw error", (t) => {
const config = assign({}, globalConfig, {
output: {
path: t.context.directory,
filename: "[id].metadata.js",
},
entry: "./test/fixtures/metadataErr.js",
});

Expand All @@ -81,8 +108,12 @@ test.serial("should throw error", (t) => {
});
});

test.serial("should pass metadata code snippet ( cache version )", (t) => {
test.cb("should pass metadata code snippet ( cache version )", (t) => {
const config = assign({}, globalConfig, {
output: {
path: t.context.directory,
filename: "[id].metadata.js",
},
module: {
loaders: [
{
Expand All @@ -105,10 +136,10 @@ test.serial("should pass metadata code snippet ( cache version )", (t) => {
webpack(config, (err) => {
t.is(err, null);

fs.readdir(outputDir, (err, files) => {
fs.readdir(t.context.directory, (err, files) => {
t.is(err, null);
t.true(files.length > 0);
fs.readFile(path.resolve(outputDir, "reactIntlMessages.json"),
fs.readFile(path.resolve(t.context.directory, "reactIntlMessages.json"),
function(err, data) {
t.is(err, null);
const text = data.toString();
Expand Down

0 comments on commit 532fb02

Please sign in to comment.