private static void fillTestCaseStructureByObjectLiteral( @NotNull JstdTestCaseStructure testCaseStructure, @NotNull JSObjectLiteralExpression testsObjectLiteral) { JSProperty[] properties = JsPsiUtils.getProperties(testsObjectLiteral); for (JSProperty property : properties) { JstdTestStructure testStructure = JstdTestStructure.newPropertyBasedTestStructure(property); if (testStructure != null) { testCaseStructure.addTestStructure(testStructure); } } }
private static void addPrototypeTest( @NotNull JstdTestCaseStructure testCaseStructure, @Nullable JSExpression rightAssignmentOperand, @NotNull JSDefinitionExpression wholeLeftDefExpr) { JSReferenceExpression wholeLeftRefExpr = ObjectUtils.tryCast(wholeLeftDefExpr.getExpression(), JSReferenceExpression.class); LeafPsiElement testMethodLeafPsiElement = null; if (wholeLeftRefExpr != null) { testMethodLeafPsiElement = ObjectUtils.tryCast(wholeLeftRefExpr.getReferenceNameElement(), LeafPsiElement.class); } if (testMethodLeafPsiElement != null && testMethodLeafPsiElement.getElementType() == JSTokenTypes.IDENTIFIER) { JSFunctionExpression jsFunctionExpression = JsPsiUtils.extractFunctionExpression(rightAssignmentOperand); JstdTestStructure jstdTestStructure = JstdTestStructure.newPrototypeBasedTestStructure( wholeLeftDefExpr, testMethodLeafPsiElement, jsFunctionExpression); if (jstdTestStructure != null) { testCaseStructure.addTestStructure(jstdTestStructure); } } }