Skip to content

Commit

Permalink
💫 cleaned up config tests, added parseWebpackConfig test #7
Browse files Browse the repository at this point in the history
  • Loading branch information
8eecf0d2 committed Oct 16, 2018
1 parent 9ca118c commit 068363e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
14 changes: 14 additions & 0 deletions test/js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const path = require("path");

module.exports = {
target: "node",
mode: "none",
entry: {
foo: "foo.js",
},
output: {
path: path.join(__dirname, "build"),
filename: "[name].js",
libraryTarget: "commonjs",
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@
publish = "default-publish"
functions = "default-functions"
command = "default-command"

[context.develop]
base = "develop-base"
publish = "develop-publish"
functions = "develop-functions"
command = "develop-command"
30 changes: 20 additions & 10 deletions test/ts/config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import { describe, it } from "mocha";
import * as mocha from "mocha";
import * as assert from "assert";

import { parseNetlifyConfig, parseWebpackConfig } from "../../src/ts";

process.env.NETLIFY_LOCAL_BRANCH = "default"

describe('Config', function() {
describe('parseNetlifyConfig', function() {
it('should throw when not found', function() {
mocha.describe('Config', () => {
mocha.describe('parseNetlifyConfig', () => {
mocha.it('should throw when not found', () => {
assert.throws(() => parseNetlifyConfig("test/toml/netlify.toml" + Math.random()));
});
it('should override build with context', function() {
const netlifyConfig = parseNetlifyConfig("test/toml/netlify-example-1.toml");
mocha.it('should override build with context', () => {
const netlifyConfig = parseNetlifyConfig("test/toml/netlify.toml");

assert.equal(netlifyConfig.build.base, `default-base`);
assert.equal(netlifyConfig.build.publish, `default-publish`);
assert.equal(netlifyConfig.build.functions, `default-functions`);
assert.equal(netlifyConfig.build.command, `default-command`);
assert.equal(netlifyConfig.build.base, "default-base");
assert.equal(netlifyConfig.build.publish, "default-publish");
assert.equal(netlifyConfig.build.functions, "default-functions");
assert.equal(netlifyConfig.build.command, "default-command");
});
});
mocha.describe('parseWebpackConfig', () => {
mocha.it('should throw when not found', () => {
assert.throws(() => parseWebpackConfig("test/js/webpack.config.js" + Math.random()));
});
mocha.it('should correctly import webpack config', () => {
const webpackConfig = parseWebpackConfig("test/js/webpack.config.js");

assert.equal(webpackConfig.target, "node");
});
});
});

0 comments on commit 068363e

Please sign in to comment.