Skip to content

Commit

Permalink
test: Add fixtures for rerender override detection
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Nov 26, 2024
1 parent 6261687 commit 0843787
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/fixtures/linter/rules/renderer/ControlRerenderOverride.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
sap.ui.define(["sap/ui/core/Control"], function(Control, Button) {
const Example1 = Control.extend("sap.ui.demo.linter.controls.Example1", {
metadata: {},

rerender: function() {
console.log("Overriding rerender method");
return Control.prototype.rerender.apply(this, arguments);
},

renderer: {
apiVersion: 2,
render: function(oRm, oControl) {
oRm.openStart("div", oControl);
oRm.openEnd();
oRm.close("div");
}
}
});

const Example2 = Control.extend("sap.ui.demo.linter.controls.Example2", {
metadata: {},

rerender: function() {
console.log("Overriding rerender method without calling super method");
},

renderer: {
apiVersion: 2,
render: function(oRm, oControl) {
oRm.openStart("div", oControl);
oRm.openEnd();
oRm.close("div");
}
}
});
});
44 changes: 44 additions & 0 deletions test/fixtures/linter/rules/renderer/ControlRerenderOverride.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Control from "sap/ui/core/Control";
import type { MetadataOptions } from "sap/ui/core/Element";
import RenderManager from "sap/ui/core/RenderManager";

/**
* @namespace sap.ui.demo.linter.controls
*/
class Example1 extends Control {
static readonly metadata: MetadataOptions = {}

rerender() {
console.log("Overriding rerender method");
return super.rerender();
}

static renderer = {
apiVersion: 2,
render: function(rm: RenderManager, control: Example1) {
rm.openStart("div", control);
rm.openEnd();
rm.close("div");
}
}
}

/**
* @namespace sap.ui.demo.linter.controls
*/
class Example2 extends Control {
static readonly metadata: MetadataOptions = {}

rerender() {
console.log("Overriding rerender method without calling super method");
}

static renderer = {
apiVersion: 2,
render: function(rm: RenderManager, control: Example1) {
rm.openStart("div", control);
rm.openEnd();
rm.close("div");
}
}
}
71 changes: 71 additions & 0 deletions test/lib/linter/rules/snapshots/renderer.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,77 @@ Generated by [AVA](https://avajs.dev).
],
warningCount: 0,
},
{
coverageInfo: [
{
category: 1,
column: 5,
line: 13,
message: 'Unable to analyze this method call because the type of identifier "openStart" in "oRm.openStart("div", oControl)"" could not be determined',
},
{
category: 1,
column: 5,
line: 14,
message: 'Unable to analyze this method call because the type of identifier "openEnd" in "oRm.openEnd()"" could not be determined',
},
{
category: 1,
column: 5,
line: 15,
message: 'Unable to analyze this method call because the type of identifier "close" in "oRm.close("div")"" could not be determined',
},
{
category: 1,
column: 5,
line: 30,
message: 'Unable to analyze this method call because the type of identifier "openStart" in "oRm.openStart("div", oControl)"" could not be determined',
},
{
category: 1,
column: 5,
line: 31,
message: 'Unable to analyze this method call because the type of identifier "openEnd" in "oRm.openEnd()"" could not be determined',
},
{
category: 1,
column: 5,
line: 32,
message: 'Unable to analyze this method call because the type of identifier "close" in "oRm.close("div")"" could not be determined',
},
],
errorCount: 1,
fatalErrorCount: 0,
filePath: 'ControlRerenderOverride.js',
messages: [
{
column: 11,
line: 7,
message: 'Use of deprecated property \'rerender\'',
messageDetails: 'Deprecated test message',
ruleId: 'no-deprecated-api',
severity: 2,
},
],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 1,
fatalErrorCount: 0,
filePath: 'ControlRerenderOverride.ts',
messages: [
{
column: 16,
line: 13,
message: 'Call to deprecated function \'rerender\' (super.rerender)',
messageDetails: 'Deprecated test message',
ruleId: 'no-deprecated-api',
severity: 2,
},
],
warningCount: 0,
},
{
coverageInfo: [],
errorCount: 3,
Expand Down
Binary file modified test/lib/linter/rules/snapshots/renderer.ts.snap
Binary file not shown.

0 comments on commit 0843787

Please sign in to comment.