Skip to content

Commit

Permalink
extend eslint rule: "no-test-only"
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Apr 6, 2023
1 parent a20d4b8 commit fdee3d4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 64 deletions.
2 changes: 2 additions & 0 deletions eslint-surveyjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = {
context.report(node, testOnlyMessage);
} else if (node.object.type === "CallExpression" && node.property.name === "only" ){
context.report(node, testOnlyMessage);
} else if (node.object.name === "QUnit" && node.property.name === "only" ){
context.report(node, testOnlyMessage);
}
}
}),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"dev": "concurrently \"http-server -p 7766 --silent\" \"npm run watch:core:dev\" \"npm run watch:core:prod\" \"npm run watch:ko:ui:dev\" \"npm run watch:react:ui:dev\" \"npm run watch:ko:ui:prod\" \"npm run watch:react:ui:prod\"",
"madge": "madge --circular --extensions ts ./src/",
"pre-push-check": "npm run lint && npm run testsingle",
"lint": "eslint ./src --quiet && eslint ./testCafe --quiet && eslint ./visualRegressionTests --quiet",
"lint": "eslint ./src --quiet && eslint ./testCafe --quiet && eslint ./tests --quiet && eslint ./visualRegressionTests --quiet",
"testsingle": "karma start ./build-scripts/karma.conf.js --single-run",
"test:knockout": "karma start ./build-scripts/survey-knockout/karma.conf.knockout.js",
"test:react": "karma start ./build-scripts/survey-react/karma.conf.react.js",
Expand Down
10 changes: 3 additions & 7 deletions tests/question_ranking_tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QuestionCheckboxModel } from "../src/question_checkbox";
import { QuestionRankingModel } from "../src/question_ranking";
import { SurveyModel } from "../src/survey";
import {settings as Settings} from "../src/settings";
import { settings as Settings } from "../src/settings";
import { Serializer } from "../src/jsonobject";

export default QUnit.module("question ranking");
Expand Down Expand Up @@ -227,7 +227,7 @@ QUnit.test("Ranking: design mode", function (assert) {
var q = <QuestionRankingModel>survey.getQuestionByName("q");
q["handleArrowUp"] = () => { upCalled++; };
q["handleArrowDown"] = () => { downCalled++; };
function preventDefault() { preventDefaultCalled++ };
function preventDefault() { preventDefaultCalled++; }

q.handleKeydown(<any>{ key: "ArrowUp", preventDefault: preventDefault }, q.choices[1]);
assert.equal(upCalled, 1);
Expand All @@ -250,7 +250,6 @@ QUnit.test("Ranking: design mode", function (assert) {
QUnit.test("Ranking: rankingDragHandleArea Setting ", function(assert) {
let result;
let dragStartTargetNode;


var survey = new SurveyModel({
elements: [
Expand All @@ -264,7 +263,6 @@ QUnit.test("Ranking: rankingDragHandleArea Setting ", function(assert) {
var rankingQuestion = <QuestionRankingModel>survey.getQuestionByName("q1");
const iconHoverClass = rankingQuestion.cssClasses.itemIconHoverMod;


Settings.rankingDragHandleArea = "icon"; // 1
dragStartTargetNode = document.createElement("div");
result = rankingQuestion["isDragStartNodeValid"](dragStartTargetNode);
Expand All @@ -273,7 +271,6 @@ QUnit.test("Ranking: rankingDragHandleArea Setting ", function(assert) {
dragStartTargetNode.classList.add(iconHoverClass);
result = rankingQuestion["isDragStartNodeValid"](dragStartTargetNode);
assert.equal(result, true);


Settings.rankingDragHandleArea = "entireItem"; // 2
result = rankingQuestion["isDragStartNodeValid"](dragStartTargetNode);
Expand All @@ -283,7 +280,6 @@ QUnit.test("Ranking: rankingDragHandleArea Setting ", function(assert) {
result = rankingQuestion["isDragStartNodeValid"](dragStartTargetNode);
assert.equal(result, true);


Settings.rankingDragHandleArea = "some"; // 3
result = rankingQuestion["isDragStartNodeValid"](dragStartTargetNode);
assert.equal(result, true);
Expand All @@ -292,5 +288,5 @@ QUnit.test("Ranking: rankingDragHandleArea Setting ", function(assert) {
QUnit.test("Ranking: separateSpecialChoices ", function (assert) {
const prop = "separateSpecialChoices";
assert.ok(Serializer.findProperty("checkbox", prop).visible, "checkbox separateSpecialChoices is visible");
assert.notOk(Serializer.findProperty("ranking", prop).visible, "ranking separateSpecialChoices is invisible")
assert.notOk(Serializer.findProperty("ranking", prop).visible, "ranking separateSpecialChoices is invisible");
});
112 changes: 56 additions & 56 deletions tests/surveyProgressButtonsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ export default QUnit.module("SurveyProgressButtons");
QUnit.test("SurveyProgressButtonsModel list elements", function(assert) {
let json: any = {
"pages": [
{
"name": "page1",
"elements": [
{
"type": "text",
"name": "question1"
}
]
},
{
"name": "page2",
"elements": [
{
"type": "text",
"name": "question2"
}
]
},
{
"name": "page3",
"elements": [
{
"type": "text",
"name": "question3"
}
]
}
{
"name": "page1",
"elements": [
{
"type": "text",
"name": "question1"
}
]
},
{
"name": "page2",
"elements": [
{
"type": "text",
"name": "question2"
}
]
},
{
"name": "page3",
"elements": [
{
"type": "text",
"name": "question3"
}
]
}
]
};
};
let survey: SurveyModel = new SurveyModel(json);
let progress: SurveyProgressButtonsModel = new SurveyProgressButtonsModel(survey);
assert.equal(progress.getListElementCss(0),
Expand Down Expand Up @@ -70,35 +70,35 @@ QUnit.test("SurveyProgressButtonsModel list elements", function(assert) {
QUnit.test("SurveyProgressButtonsModel list elements non clickable", function(assert) {
let json: any = {
"pages": [
{
"name": "page1",
"elements": [
{
"type": "text",
"name": "question1"
}
]
},
{
"name": "page2",
"elements": [
{
"type": "text",
"name": "question2"
}
]
},
{
"name": "page3",
"elements": [
{
"type": "text",
"name": "question3"
}
]
}
{
"name": "page1",
"elements": [
{
"type": "text",
"name": "question1"
}
]
},
{
"name": "page2",
"elements": [
{
"type": "text",
"name": "question2"
}
]
},
{
"name": "page3",
"elements": [
{
"type": "text",
"name": "question3"
}
]
}
]
};
};
let survey: SurveyModel = new SurveyModel(json);
survey.onServerValidateQuestions.add((_: any, options: any) => options.complete());
let progress: SurveyProgressButtonsModel = new SurveyProgressButtonsModel(survey);
Expand Down

0 comments on commit fdee3d4

Please sign in to comment.