New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests and lint #211
Fix tests and lint #211
Changes from 6 commits
444cb82
df2d7d9
e1c783e
7ba5297
7abdace
99e8f3e
2a399c5
4a9240e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,6 @@ describe("config-loader", (): void => { | |
}); | ||
|
||
const successResult = result as ConfigLoaderSuccessResult; | ||
// assert.equal(successResult.resultType, "success"); | ||
// assert.equal(successResult.absoluteBaseUrl, "/foo/bar"); | ||
// assert.equal(successResult.paths["asd"][0], "asd"); | ||
expect(successResult.resultType).toBe("success"); | ||
expect(successResult.absoluteBaseUrl).toBe("/foo/bar"); | ||
expect(successResult.paths["asd"][0]).toBe("asd"); | ||
|
@@ -39,8 +36,6 @@ describe("config-loader", (): void => { | |
}); | ||
|
||
const successResult = result as ConfigLoaderSuccessResult; | ||
// assert.equal(successResult.resultType, "success"); | ||
// assert.equal(successResult.absoluteBaseUrl, join("/baz", "bar/")); | ||
expect(successResult.resultType).toBe("success"); | ||
expect(successResult.absoluteBaseUrl).toBe(join("/baz", "bar/")); | ||
}); | ||
|
@@ -49,38 +44,31 @@ describe("config-loader", (): void => { | |
const result = configLoader({ | ||
explicitParams: undefined, | ||
cwd: "/baz", | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
tsConfigLoader: (_: any) => ({ | ||
tsConfigLoader: () => ({ | ||
tsConfigPath: "/baz/tsconfig.json", | ||
baseUrl: "./src", | ||
paths: {}, | ||
}), | ||
}); | ||
|
||
const successResult = result as ConfigLoaderSuccessResult; | ||
// assert.equal(successResult.resultType, "success"); | ||
// assert.equal(successResult.absoluteBaseUrl, join("/baz", "src")); | ||
expect(successResult.resultType).toBe("success"); | ||
expect(successResult.absoluteBaseUrl).toBe(join("/baz", "src")); | ||
}); | ||
|
||
it("should show an error message when baseUrl is missing", () => { | ||
it("should tolerate a missing baseUrl", () => { | ||
const result = configLoader({ | ||
explicitParams: undefined, | ||
cwd: "/baz", | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
tsConfigLoader: (_: any) => ({ | ||
tsConfigLoader: () => ({ | ||
tsConfigPath: "/baz/tsconfig.json", | ||
baseUrl: undefined, | ||
paths: {}, | ||
}), | ||
}); | ||
|
||
const failResult = result as ConfigLoaderFailResult; | ||
// assert.equal(failResult.resultType, "failed"); | ||
// assert.isTrue(failResult.message.indexOf("baseUrl") > -1); | ||
expect(failResult.resultType).toBe("failed"); | ||
expect(failResult.message.indexOf("baseUrl") > -1).toBeTruthy(); | ||
expect(failResult.resultType).toBe("success"); | ||
}); | ||
|
||
it("should presume cwd to be a tsconfig file when loadConfig is called with absolute path to tsconfig.json", () => { | ||
|
@@ -92,8 +80,6 @@ describe("config-loader", (): void => { | |
const result = loadConfig(configFile); | ||
|
||
const successResult = result as ConfigLoaderSuccessResult; | ||
// assert.equal(successResult.resultType, "success"); | ||
// assert.equal(successResult.configFileAbsolutePath, configFile); | ||
expect(successResult.resultType).toBe("success"); | ||
expect(successResult.configFileAbsolutePath).toBe(configFile); | ||
}); | ||
|
@@ -102,15 +88,14 @@ describe("config-loader", (): void => { | |
const result = configLoader({ | ||
explicitParams: undefined, | ||
cwd: "/baz", | ||
// tslint:disable-next-line:no-any | ||
tsConfigLoader: (_: any) => ({ | ||
tsConfigLoader: () => ({ | ||
tsConfigPath: "/baz/tsconfig.json", | ||
baseUrl: "/baz", | ||
paths: {}, | ||
}), | ||
}); | ||
|
||
const successResult = result as ConfigLoaderSuccessResult; | ||
assert.equal(successResult.absoluteBaseUrl, "/baz"); | ||
expect(successResult.absoluteBaseUrl).toEqual("/baz"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the failing test from #174. |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,56 +6,30 @@ describe("mapping-entry", () => { | |
const result = getAbsoluteMappingEntries( | ||
"/absolute/base/url", | ||
{ | ||
"*": ["/foo1", "/foo2"], | ||
"longest/pre/fix/*": ["/foo2/bar"], | ||
"*": ["/foo1", "./foo2"], | ||
"longest/pre/fix/*": ["./foo2/bar"], | ||
"pre/fix/*": ["/foo3"], | ||
}, | ||
true | ||
); | ||
// assert.deepEqual(result, [ | ||
// { | ||
// pattern: "longest/pre/fix/*", | ||
// paths: [join("/absolute", "base", "url", "foo2", "bar")], | ||
// }, | ||
// { | ||
// pattern: "pre/fix/*", | ||
// paths: [join("/absolute", "base", "url", "foo3")], | ||
// }, | ||
// { | ||
// pattern: "*", | ||
// paths: [ | ||
// join("/absolute", "base", "url", "foo1"), | ||
// join("/absolute", "base", "url", "foo2"), | ||
// ], | ||
// }, | ||
// ]); | ||
expect(result).toEqual([ | ||
{ | ||
pattern: "longest/pre/fix/*", | ||
paths: [join("/absolute", "base", "url", "foo2", "bar")], | ||
}, | ||
{ | ||
pattern: "pre/fix/*", | ||
paths: [join("/absolute", "base", "url", "foo3")], | ||
paths: [join("/foo3")], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe these test cases were broken by #184. I updated them to have a sampling of both relative and absolute paths. |
||
}, | ||
{ | ||
pattern: "*", | ||
paths: [ | ||
join("/absolute", "base", "url", "foo1"), | ||
join("/absolute", "base", "url", "foo2"), | ||
], | ||
paths: [join("/foo1"), join("/absolute", "base", "url", "foo2")], | ||
}, | ||
]); | ||
}); | ||
|
||
it("should should add a match-all pattern when requested", () => { | ||
let result = getAbsoluteMappingEntries("/absolute/base/url", {}, true); | ||
// assert.deepEqual(result, [ | ||
// { | ||
// pattern: "*", | ||
// paths: [join("/absolute", "base", "url", "*")], | ||
// }, | ||
// ]); | ||
expect(result).toEqual([ | ||
{ | ||
pattern: "*", | ||
|
@@ -64,7 +38,6 @@ describe("mapping-entry", () => { | |
]); | ||
|
||
result = getAbsoluteMappingEntries("/absolute/base/url", {}, false); | ||
// assert.deepEqual(result, []); | ||
expect(result).toEqual([]); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this test was broken by #208.