Skip to content

Commit 9a4cff3

Browse files
anikethsahaKai Cataldo
andauthored
Chore: added tests for options normalize (#439)
* Chore: added tests for options normalize * Chore: changed test description to normalizeOptions Co-Authored-By: Kai Cataldo <[email protected]> Co-authored-by: Kai Cataldo <[email protected]>
1 parent 99707f3 commit 9a4cff3

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

tests/lib/options.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* @fileoverview Tests for options.
3+
* @author Aniketh Saha
4+
*/
5+
6+
"use strict";
7+
8+
//------------------------------------------------------------------------------
9+
// Requirements
10+
//------------------------------------------------------------------------------
11+
12+
const assert = require("assert"),
13+
{ normalizeOptions } = require("../../lib/options");
14+
15+
//------------------------------------------------------------------------------
16+
// Tests
17+
//------------------------------------------------------------------------------
18+
19+
describe("normalizeOptions", () => {
20+
it("should throw error for sourceType module and ecmaVersion < 6", () => {
21+
const option = {
22+
sourceType: "module",
23+
ecmaVersion: 5
24+
};
25+
26+
assert.throws(() => {
27+
normalizeOptions(option);
28+
});
29+
});
30+
31+
it("should normalize the ecmaVersion from year to version number", () => {
32+
const option = {
33+
ecmaVersion: 2018
34+
};
35+
36+
const output = normalizeOptions(option);
37+
38+
assert.strictEqual(output.ecmaVersion, 9);
39+
});
40+
41+
it("should throw error for unsupported ecmaVersion", () => {
42+
const option = {
43+
ecmaVersion: 2040
44+
};
45+
46+
assert.throws(() => {
47+
normalizeOptions(option);
48+
});
49+
});
50+
51+
it("should throw error for unsupported sourceType", () => {
52+
const option = {
53+
sourceType: "esm"
54+
};
55+
56+
assert.throws(() => {
57+
normalizeOptions(option);
58+
});
59+
});
60+
});

0 commit comments

Comments
 (0)