Skip to content

Commit

Permalink
💫 added simple test for parseNetlifyConfig to get #7 rolling
Browse files Browse the repository at this point in the history
  • Loading branch information
8eecf0d2 committed Oct 16, 2018
1 parent 9fbcacf commit a5e7bd4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/toml/netlify-example-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[build]
base = "default-base"
publish = "default-publish"
functions = "default-functions"
command = "default-command"

[context.master]
base = "master-base"
publish = "master-publish"
functions = "master-functions"
command = "master-command"

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

import * as gitBranch from "git-branch";

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

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

assert.equal(netlifyConfig.build.base, `${currentBranch}-base`);
assert.equal(netlifyConfig.build.publish, `${currentBranch}-publish`);
assert.equal(netlifyConfig.build.functions, `${currentBranch}-functions`);
assert.equal(netlifyConfig.build.command, `${currentBranch}-command`);
});
});
});

0 comments on commit a5e7bd4

Please sign in to comment.