Skip to content

Commit

Permalink
refactor: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Mar 22, 2024
1 parent 0bbf0c4 commit 04d5304
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,10 @@
* Initialization Code and shared classes of library library.with.custom.paths.
*/
sap.ui.define([
"sap/ui/core/library",
"sap/ui/core/Lib",
], function (coreLib, Library) {
"sap/ui/core/library"
], function () {
"use strict";

Library.init();
Library.init("a");
Library.init({});
Library.init({
test: 12
});
Library.init({
apiVersion: "23"
});
Library.init({
apiVersion: 11
});
Library.init({
apiVersion: "2"
});
Library.init({
apiVersion: 2
});

// Should be ignored
Library.load({
apiVersion: 23
})


// delegate further initialization of this library to the Core
// Hint: sap.ui.getCore() must still be used to support preload with sync bootstrap!
sap.ui.getCore().initLibrary({
Expand Down
36 changes: 36 additions & 0 deletions test/fixtures/linter/rules/NoDeprecatedApi/old_library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*!
* ${copyright}
*/

/**
* Initialization Code and shared classes of library library.with.custom.paths.
*/
sap.ui.define([
"sap/ui/core/Lib",
], function (Library) {
"use strict";

Library.init();
Library.init("a");
Library.init({});
Library.init({
test: 12
});
Library.init({
apiVersion: "23"
});
Library.init({
apiVersion: 11
});
Library.init({
apiVersion: "2"
});
Library.init({
apiVersion: 2
});

// Should be ignored
Library.load({
apiVersion: 23
});
});
72 changes: 72 additions & 0 deletions test/lib/linter/rules/snapshots/NoDeprecatedApi.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,78 @@ Generated by [AVA](https://avajs.dev).
},
]

## General: old_library.js

> Snapshot 1
[
{
coverageInfo: [],
errorCount: 7,
fatalErrorCount: 0,
filePath: 'old_library.js',
messages: [
{
column: 2,
fatal: undefined,
line: 13,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 2,
fatal: undefined,
line: 14,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 2,
fatal: undefined,
line: 15,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 2,
fatal: undefined,
line: 16,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 15,
fatal: undefined,
line: 20,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 15,
fatal: undefined,
line: 23,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 15,
fatal: undefined,
line: 26,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
],
warningCount: 0,
},
]

## General: sap.ui.jsview.js

> Snapshot 1
Expand Down
60 changes: 2 additions & 58 deletions test/lib/linter/snapshots/linter.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -900,70 +900,14 @@ Generated by [AVA](https://avajs.dev).
},
{
coverageInfo: [],
errorCount: 9,
errorCount: 2,
fatalErrorCount: 0,
filePath: 'src/main/js/library.js',
messages: [
{
column: 2,
fatal: undefined,
line: 14,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 2,
fatal: undefined,
line: 15,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 2,
fatal: undefined,
line: 16,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 2,
fatal: undefined,
line: 17,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 15,
fatal: undefined,
line: 21,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 15,
fatal: undefined,
line: 24,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 15,
fatal: undefined,
line: 27,
message: 'Call to Library.init() must be declared with property {apiVersion: 2}',
ruleId: 'ui5-linter-no-partially-deprecated-api',
severity: 2,
},
{
column: 2,
fatal: undefined,
line: 41,
message: 'Call to deprecated function \'initLibrary\' of class \'Core\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
Expand All @@ -972,7 +916,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 2,
fatal: undefined,
line: 41,
line: 14,
message: 'Call to deprecated function \'getCore\' (sap.ui.getCore)',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
Expand Down
Binary file modified test/lib/linter/snapshots/linter.ts.snap
Binary file not shown.

0 comments on commit 04d5304

Please sign in to comment.