-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INTERNAL] Enable stricter parsing of analyseLibraryJS
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
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
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,42 @@ | ||
const test = require("ava"); | ||
const sinon = require("sinon"); | ||
const mock = require("mock-require"); | ||
|
||
function createMockResource(libraryJS) { | ||
return { | ||
async getBuffer() { | ||
return libraryJS; | ||
} | ||
}; | ||
} | ||
|
||
test("analyze: library.js with non supported property", (t) => { | ||
const libraryjs = `sap.ui.define([ | ||
'sap/ui/core/Core', | ||
], function(Core) { | ||
"use strict"; | ||
sap.ui.getCore().initLibrary({ | ||
name : "library.test", | ||
customProperty: "UI5" | ||
}); | ||
return thisLib; | ||
});`; | ||
|
||
const logger = require("@ui5/logger"); | ||
const errorLogStub = sinon.stub(); | ||
const myLoggerInstance = { | ||
error: errorLogStub | ||
}; | ||
sinon.stub(logger, "getLogger").returns(myLoggerInstance); | ||
const analyzeLibraryJSWithStubbedLogger = mock.reRequire("../../../../lib/lbt/analyzer/analyzeLibraryJS"); | ||
|
||
const mockResource = createMockResource(libraryjs); | ||
|
||
analyzeLibraryJSWithStubbedLogger(mockResource); | ||
|
||
t.is(errorLogStub.callCount, 1, "Error log is called once"); | ||
}); |