-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: added tests for options normalize (#439)
* 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
1 parent
99707f3
commit 9a4cff3
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |