Skip to content

Commit

Permalink
Chore: added tests for options normalize (#439)
Browse files Browse the repository at this point in the history
* Chore: added tests for options normalize

* Chore: changed test description to normalizeOptions

Co-Authored-By: Kai Cataldo <kai@kaicataldo.com>

Co-authored-by: Kai Cataldo <kai@kaicataldo.com>
  • Loading branch information
anikethsaha and kaicataldo committed Apr 24, 2020
1 parent 99707f3 commit 9a4cff3
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/lib/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @fileoverview Tests for options.
* @author Aniketh Saha
*/

"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

const assert = require("assert"),
{ normalizeOptions } = require("../../lib/options");

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

describe("normalizeOptions", () => {
it("should throw error for sourceType module and ecmaVersion < 6", () => {
const option = {
sourceType: "module",
ecmaVersion: 5
};

assert.throws(() => {
normalizeOptions(option);
});
});

it("should normalize the ecmaVersion from year to version number", () => {
const option = {
ecmaVersion: 2018
};

const output = normalizeOptions(option);

assert.strictEqual(output.ecmaVersion, 9);
});

it("should throw error for unsupported ecmaVersion", () => {
const option = {
ecmaVersion: 2040
};

assert.throws(() => {
normalizeOptions(option);
});
});

it("should throw error for unsupported sourceType", () => {
const option = {
sourceType: "esm"
};

assert.throws(() => {
normalizeOptions(option);
});
});
});

0 comments on commit 9a4cff3

Please sign in to comment.