@testgorilla/tgo-coding-test 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/.eslintrc.json +45 -0
  2. package/README.md +257 -0
  3. package/jest.config.ts +21 -0
  4. package/ng-package.json +14 -0
  5. package/package.json +33 -0
  6. package/project.json +36 -0
  7. package/src/assets/i18n/en.json +124 -0
  8. package/src/index.ts +30 -0
  9. package/src/lib/components/.gitkeep +0 -0
  10. package/src/lib/components/code-editor/code-editor.component.html +10 -0
  11. package/src/lib/components/code-editor/code-editor.component.scss +21 -0
  12. package/src/lib/components/code-editor/code-editor.component.spec.ts +136 -0
  13. package/src/lib/components/code-editor/code-editor.component.ts +369 -0
  14. package/src/lib/components/code-editor/code-editor.mocks.ts +28 -0
  15. package/src/lib/components/code-editor/code-editor.service.spec.ts +160 -0
  16. package/src/lib/components/code-editor/code-editor.service.ts +94 -0
  17. package/src/lib/components/code-editor/helpers/c-helper.spec.ts +39 -0
  18. package/src/lib/components/code-editor/helpers/c-helper.ts +51 -0
  19. package/src/lib/components/code-editor/helpers/code-editor-helper.base.spec.ts +30 -0
  20. package/src/lib/components/code-editor/helpers/code-editor-helper.base.ts +16 -0
  21. package/src/lib/components/code-editor/helpers/code-editor-helper.mocks.ts +24 -0
  22. package/src/lib/components/code-editor/helpers/code-editor-helper.model.ts +67 -0
  23. package/src/lib/components/code-editor/helpers/cpp-helper.spec.ts +40 -0
  24. package/src/lib/components/code-editor/helpers/cpp-helper.ts +52 -0
  25. package/src/lib/components/code-editor/helpers/csharp-helper.spec.ts +42 -0
  26. package/src/lib/components/code-editor/helpers/csharp-helper.ts +55 -0
  27. package/src/lib/components/code-editor/helpers/go-helper.spec.ts +41 -0
  28. package/src/lib/components/code-editor/helpers/go-helper.ts +54 -0
  29. package/src/lib/components/code-editor/helpers/index.ts +15 -0
  30. package/src/lib/components/code-editor/helpers/java-helper.spec.ts +41 -0
  31. package/src/lib/components/code-editor/helpers/java-helper.ts +54 -0
  32. package/src/lib/components/code-editor/helpers/javascript-helper.spec.ts +39 -0
  33. package/src/lib/components/code-editor/helpers/javascript-helper.ts +32 -0
  34. package/src/lib/components/code-editor/helpers/kotlin-helper.spec.ts +41 -0
  35. package/src/lib/components/code-editor/helpers/kotlin-helper.ts +54 -0
  36. package/src/lib/components/code-editor/helpers/php-helper.spec.ts +39 -0
  37. package/src/lib/components/code-editor/helpers/php-helper.ts +32 -0
  38. package/src/lib/components/code-editor/helpers/python-helper.spec.ts +39 -0
  39. package/src/lib/components/code-editor/helpers/python-helper.ts +32 -0
  40. package/src/lib/components/code-editor/helpers/r-helper.spec.ts +39 -0
  41. package/src/lib/components/code-editor/helpers/r-helper.ts +32 -0
  42. package/src/lib/components/code-editor/helpers/ruby-helper.spec.ts +39 -0
  43. package/src/lib/components/code-editor/helpers/ruby-helper.ts +32 -0
  44. package/src/lib/components/code-editor/helpers/scala-helper.spec.ts +41 -0
  45. package/src/lib/components/code-editor/helpers/scala-helper.ts +53 -0
  46. package/src/lib/components/code-editor/helpers/sql-helper.spec.ts +87 -0
  47. package/src/lib/components/code-editor/helpers/sql-helper.ts +44 -0
  48. package/src/lib/components/code-editor/helpers/swift-helper.spec.ts +40 -0
  49. package/src/lib/components/code-editor/helpers/swift-helper.ts +51 -0
  50. package/src/lib/components/code-editor/helpers/typescript-helper.spec.ts +40 -0
  51. package/src/lib/components/code-editor/helpers/typescript-helper.ts +52 -0
  52. package/src/lib/components/code-editor/models/code-editor.model.ts +9 -0
  53. package/src/lib/components/code-editor/models/coding-snapshot.model.ts +4 -0
  54. package/src/lib/components/coding-question/coding-question.component.html +78 -0
  55. package/src/lib/components/coding-question/coding-question.component.scss +76 -0
  56. package/src/lib/components/coding-question/coding-question.component.spec.ts +85 -0
  57. package/src/lib/components/coding-question/coding-question.component.ts +102 -0
  58. package/src/lib/components/coding-section/coding-section.component.html +82 -0
  59. package/src/lib/components/coding-section/coding-section.component.scss +64 -0
  60. package/src/lib/components/coding-section/coding-section.component.spec.ts +257 -0
  61. package/src/lib/components/coding-section/coding-section.component.ts +187 -0
  62. package/src/lib/components/coding-test.module.ts +124 -0
  63. package/src/lib/components/common/truncated-text/truncated-text.component.html +6 -0
  64. package/src/lib/components/common/truncated-text/truncated-text.component.scss +18 -0
  65. package/src/lib/components/common/truncated-text/truncated-text.component.spec.ts +84 -0
  66. package/src/lib/components/common/truncated-text/truncated-text.component.ts +37 -0
  67. package/src/lib/components/configurations/configurations.component.html +57 -0
  68. package/src/lib/components/configurations/configurations.component.scss +42 -0
  69. package/src/lib/components/configurations/configurations.component.spec.ts +186 -0
  70. package/src/lib/components/configurations/configurations.component.ts +98 -0
  71. package/src/lib/components/instructions/instructions.component.html +41 -0
  72. package/src/lib/components/instructions/instructions.component.scss +167 -0
  73. package/src/lib/components/instructions/instructions.component.spec.ts +106 -0
  74. package/src/lib/components/instructions/instructions.component.ts +138 -0
  75. package/src/lib/components/panel/panel.component.html +19 -0
  76. package/src/lib/components/panel/panel.component.scss +41 -0
  77. package/src/lib/components/panel/panel.component.spec.ts +40 -0
  78. package/src/lib/components/panel/panel.component.ts +34 -0
  79. package/src/lib/components/runnable-editor/runnable-editor.component.html +75 -0
  80. package/src/lib/components/runnable-editor/runnable-editor.component.scss +55 -0
  81. package/src/lib/components/runnable-editor/runnable-editor.component.spec.ts +124 -0
  82. package/src/lib/components/runnable-editor/runnable-editor.component.ts +155 -0
  83. package/src/lib/components/tests/test-cases/test-cases.component.html +135 -0
  84. package/src/lib/components/tests/test-cases/test-cases.component.scss +220 -0
  85. package/src/lib/components/tests/test-cases/test-cases.component.spec.ts +401 -0
  86. package/src/lib/components/tests/test-cases/test-cases.component.ts +205 -0
  87. package/src/lib/components/tests/test-cases-content/test-cases-content.component.html +94 -0
  88. package/src/lib/components/tests/test-cases-content/test-cases-content.component.scss +103 -0
  89. package/src/lib/components/tests/test-cases-content/test-cases-content.component.spec.ts +122 -0
  90. package/src/lib/components/tests/test-cases-content/test-cases-content.component.ts +102 -0
  91. package/src/lib/components/tests/test-cases-status/test-cases-status.component.html +16 -0
  92. package/src/lib/components/tests/test-cases-status/test-cases-status.component.scss +49 -0
  93. package/src/lib/components/tests/test-cases-status/test-cases-status.component.spec.ts +22 -0
  94. package/src/lib/components/tests/test-cases-status/test-cases-status.component.ts +18 -0
  95. package/src/lib/components/tests/test-results.component.html +119 -0
  96. package/src/lib/components/tests/test-results.component.scss +189 -0
  97. package/src/lib/components/tests/test-results.component.spec.ts +140 -0
  98. package/src/lib/components/tests/test-results.component.ts +98 -0
  99. package/src/lib/components/tgo-coding-test/tgo-coding-test.component.html +96 -0
  100. package/src/lib/components/tgo-coding-test/tgo-coding-test.component.scss +6 -0
  101. package/src/lib/components/tgo-coding-test/tgo-coding-test.component.spec.ts +599 -0
  102. package/src/lib/components/tgo-coding-test/tgo-coding-test.component.ts +279 -0
  103. package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.html +36 -0
  104. package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.scss +183 -0
  105. package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.spec.ts +883 -0
  106. package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.ts +575 -0
  107. package/src/lib/config/index.ts +3 -0
  108. package/src/lib/config/tgo-coding-test.config.ts +26 -0
  109. package/src/lib/config/tgo-coding-test.provider.ts +38 -0
  110. package/src/lib/config/tgo-coding-test.token.ts +21 -0
  111. package/src/lib/models/.gitkeep +0 -0
  112. package/src/lib/models/auto-saved-data.ts +51 -0
  113. package/src/lib/models/code-event.ts +17 -0
  114. package/src/lib/models/coderunner-execution-results.ts +58 -0
  115. package/src/lib/models/coding-lib.mocks.ts +246 -0
  116. package/src/lib/models/configs.ts +18 -0
  117. package/src/lib/models/language-change-action.ts +4 -0
  118. package/src/lib/models/lat-languages.ts +12 -0
  119. package/src/lib/models/mixpanel-events.ts +3 -0
  120. package/src/lib/models/mode.ts +5 -0
  121. package/src/lib/models/paste-data.ts +4 -0
  122. package/src/lib/models/programming-language.ts +9 -0
  123. package/src/lib/models/test-cases.ts +74 -0
  124. package/src/lib/models/theme.ts +5 -0
  125. package/src/lib/models/translations.ts +1 -0
  126. package/src/lib/models/view-mode.ts +6 -0
  127. package/src/lib/pipes/memoize-func.pipe.ts +34 -0
  128. package/src/lib/services/.gitkeep +0 -0
  129. package/src/lib/services/candidate-coding-test-services/candidature-api.service.spec.ts +40 -0
  130. package/src/lib/services/candidate-coding-test-services/candidature-api.service.ts +15 -0
  131. package/src/lib/services/candidate-coding-test-services/coderunner-api.service.spec.ts +134 -0
  132. package/src/lib/services/candidate-coding-test-services/coderunner-api.service.ts +105 -0
  133. package/src/lib/services/candidate-coding-test-services/coding-test-tour.service.spec.ts +161 -0
  134. package/src/lib/services/candidate-coding-test-services/coding-test-tour.service.ts +100 -0
  135. package/src/lib/services/candidate-coding-test-services/coding-test.service.spec.ts +1524 -0
  136. package/src/lib/services/candidate-coding-test-services/coding-test.service.ts +843 -0
  137. package/src/lib/services/candidate-coding-test-services/index.ts +4 -0
  138. package/src/lib/services/coding-test-config.service.ts +48 -0
  139. package/src/lib/services/configurations.service.mocks.ts +77 -0
  140. package/src/lib/services/configurations.service.spec.ts +79 -0
  141. package/src/lib/services/configurations.service.ts +111 -0
  142. package/src/lib/services/index.ts +0 -0
  143. package/src/lib/services/lib-coding-test.service.spec.ts +265 -0
  144. package/src/lib/services/lib-coding-test.service.ts +157 -0
  145. package/src/lib/services/local-storage.service.mocks.ts +22 -0
  146. package/src/lib/services/storage.service.spec.ts +1120 -0
  147. package/src/lib/services/storage.service.ts +729 -0
  148. package/src/lib/services/test-cases.service.spec.ts +53 -0
  149. package/src/lib/services/test-cases.service.ts +29 -0
  150. package/src/lib/services/theme.service.spec.ts +76 -0
  151. package/src/lib/services/theme.service.ts +34 -0
  152. package/src/lib/styles/mixins.scss +86 -0
  153. package/src/lib/styles/styles.scss +112 -0
  154. package/src/lib/styles/variables.scss +105 -0
  155. package/src/lib/utils/.gitkeep +0 -0
  156. package/src/lib/utils/additional-languages/erlang.ts +115 -0
  157. package/src/lib/utils/resize-element.ts +15 -0
  158. package/src/lib/utils/time-to-ms.util.ts +10 -0
  159. package/src/test-setup.ts +1 -0
  160. package/tsconfig.json +16 -0
  161. package/tsconfig.lib.json +12 -0
  162. package/tsconfig.lib.prod.json +9 -0
  163. package/tsconfig.spec.json +13 -0
@@ -0,0 +1,54 @@
1
+ import { CodeEditorHelperBase } from './code-editor-helper.base';
2
+ import {
3
+ CodeEditorFuncOptions,
4
+ CodeEditorHelper,
5
+ CodeEditorLanguages,
6
+ CodeEditorTypesMap,
7
+ } from './code-editor-helper.model';
8
+
9
+ export class CodeEditorJavaHelper extends CodeEditorHelperBase implements CodeEditorHelper {
10
+ language = CodeEditorLanguages.Java;
11
+ typesMap: CodeEditorTypesMap = {
12
+ boolean: 'Boolean',
13
+ int: 'Integer',
14
+ number: 'Integer',
15
+ double: 'Double',
16
+ float: 'Float',
17
+ str: 'String',
18
+ array_boolean: 'Boolean[]',
19
+ array_int: 'Integer[]',
20
+ array_float: 'Float[]',
21
+ array_double: 'Double[]',
22
+ array_str: 'String[]',
23
+ };
24
+
25
+ private classOpening = 'public class TestTaker {\n';
26
+
27
+ constructor(private functionOptions: CodeEditorFuncOptions) {
28
+ super();
29
+ }
30
+
31
+ getInitCode(): string {
32
+ return `${this.classOpening}${this.getFunctionOpening()}\t\t //Insert your code here \n\t}\n`;
33
+ }
34
+
35
+ getFunctionOpening(): string {
36
+ const { name: funcName, returnType } = this.functionOptions;
37
+ const params = this.getParamsString();
38
+ const showingReturnType = this.parseType(returnType);
39
+
40
+ return `\tpublic static ${showingReturnType} ${funcName}(${params}) {\n`;
41
+ }
42
+
43
+ private getParamsString(): string {
44
+ const { params } = this.functionOptions;
45
+ let paramsString = '';
46
+
47
+ if (params && params.length > 0) {
48
+ params.forEach(values => (paramsString += `${this.parseType(values.type)} ${values.name}, `));
49
+ paramsString = paramsString.slice(0, -2);
50
+ }
51
+
52
+ return paramsString;
53
+ }
54
+ }
@@ -0,0 +1,39 @@
1
+ import { defaultFuncParams } from './code-editor-helper.mocks';
2
+ import { CodeEditorJavascriptHelper } from './javascript-helper';
3
+
4
+ describe('CodeEditorJavascriptHelper', () => {
5
+ let helper: CodeEditorJavascriptHelper;
6
+
7
+ const defaultParams = { ...defaultFuncParams };
8
+ const paramsList = 'param1, param2, param3, param4, param5, param6, param7, param8';
9
+ const correctFuncOpening = `export function mockFunction(${paramsList}) {\n`;
10
+ const correctInitCode = `${correctFuncOpening}\t //Insert your code here \n}`;
11
+
12
+ beforeEach(() => {
13
+ helper = new CodeEditorJavascriptHelper(defaultParams);
14
+ });
15
+
16
+ describe('when getting init code', () => {
17
+ let result: string;
18
+
19
+ beforeEach(() => {
20
+ result = helper.getInitCode();
21
+ });
22
+
23
+ it('should return proper init code', () => {
24
+ expect(result).toEqual(correctInitCode);
25
+ });
26
+ });
27
+
28
+ describe('when getting func opening', () => {
29
+ let result: string;
30
+
31
+ beforeEach(() => {
32
+ result = helper.getFunctionOpening();
33
+ });
34
+
35
+ it('should return proper func opening', () => {
36
+ expect(result).toEqual(correctFuncOpening);
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,32 @@
1
+ import { CodeEditorHelperBase } from './code-editor-helper.base';
2
+ import { CodeEditorFuncOptions, CodeEditorHelper, CodeEditorLanguages } from './code-editor-helper.model';
3
+
4
+ export class CodeEditorJavascriptHelper extends CodeEditorHelperBase implements CodeEditorHelper {
5
+ language = CodeEditorLanguages.Javascript;
6
+
7
+ constructor(private functionOptions: CodeEditorFuncOptions) {
8
+ super();
9
+ }
10
+
11
+ getInitCode(): string {
12
+ return `${this.getFunctionOpening()}\t //Insert your code here \n}`;
13
+ }
14
+
15
+ getFunctionOpening(): string {
16
+ const { name: funcName } = this.functionOptions;
17
+
18
+ return `export function ${funcName}(${this.getParamsString()}) {\n`;
19
+ }
20
+
21
+ private getParamsString(): string {
22
+ const { params } = this.functionOptions;
23
+ let paramsString = '';
24
+
25
+ if (params && params.length > 0) {
26
+ params.forEach(values => (paramsString += `${values.name}, `));
27
+ paramsString = paramsString.slice(0, -2);
28
+ }
29
+
30
+ return paramsString;
31
+ }
32
+ }
@@ -0,0 +1,41 @@
1
+ import { defaultFuncParams } from './code-editor-helper.mocks';
2
+ import { CodeEditorKotlinHelper } from './kotlin-helper';
3
+
4
+ describe('CodeEditorKotlinHelper', () => {
5
+ let helper: CodeEditorKotlinHelper;
6
+
7
+ const defaultParams = { ...defaultFuncParams };
8
+ const paramsList =
9
+ 'param1: Boolean, param2: Int, param3: Double, param4: Float, param5: String, param6: Array<Boolean>, param7: Array<Int>, param8: Array<Float>';
10
+ const packages = 'package com.testgorilla.testtaker\n';
11
+ const correctFuncOpening = `fun mockFunction(${paramsList}): Boolean {\n`;
12
+ const correctInitCode = `${packages}${correctFuncOpening}\t //Insert your code here \n}`;
13
+
14
+ beforeEach(() => {
15
+ helper = new CodeEditorKotlinHelper(defaultParams);
16
+ });
17
+
18
+ describe('when getting init code', () => {
19
+ let result: string;
20
+
21
+ beforeEach(() => {
22
+ result = helper.getInitCode();
23
+ });
24
+
25
+ it('should return proper init code', () => {
26
+ expect(result).toEqual(correctInitCode);
27
+ });
28
+ });
29
+
30
+ describe('when getting func opening', () => {
31
+ let result: string;
32
+
33
+ beforeEach(() => {
34
+ result = helper.getFunctionOpening();
35
+ });
36
+
37
+ it('should return proper func opening', () => {
38
+ expect(result).toEqual(correctFuncOpening);
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,54 @@
1
+ import { CodeEditorHelperBase } from './code-editor-helper.base';
2
+ import {
3
+ CodeEditorFuncOptions,
4
+ CodeEditorHelper,
5
+ CodeEditorLanguages,
6
+ CodeEditorTypesMap,
7
+ } from './code-editor-helper.model';
8
+
9
+ export class CodeEditorKotlinHelper extends CodeEditorHelperBase implements CodeEditorHelper {
10
+ language = CodeEditorLanguages.Kotlin;
11
+ typesMap: CodeEditorTypesMap = {
12
+ boolean: 'Boolean',
13
+ int: 'Int',
14
+ number: 'int',
15
+ double: 'Double',
16
+ float: 'Float',
17
+ str: 'String',
18
+ array_boolean: 'Array<Boolean>',
19
+ array_int: 'Array<Int>',
20
+ array_float: 'Array<Float>',
21
+ array_double: 'Array<Double>',
22
+ array_str: 'Array<String>',
23
+ };
24
+
25
+ private packagesText = 'package com.testgorilla.testtaker\n';
26
+
27
+ constructor(private functionOptions: CodeEditorFuncOptions) {
28
+ super();
29
+ }
30
+
31
+ getInitCode(): string {
32
+ return `${this.packagesText}${this.getFunctionOpening()}\t //Insert your code here \n}`;
33
+ }
34
+
35
+ getFunctionOpening(): string {
36
+ const { name: funcName, returnType } = this.functionOptions;
37
+ const params = this.getParamsString();
38
+ const showingReturnType = this.parseType(returnType);
39
+
40
+ return `fun ${funcName}(${params}): ${showingReturnType} {\n`;
41
+ }
42
+
43
+ private getParamsString(): string {
44
+ const { params } = this.functionOptions;
45
+ let paramsString = '';
46
+
47
+ if (params && params.length > 0) {
48
+ params.forEach(values => (paramsString += `${values.name}: ${this.parseType(values.type)}, `));
49
+ paramsString = paramsString.slice(0, -2);
50
+ }
51
+
52
+ return paramsString;
53
+ }
54
+ }
@@ -0,0 +1,39 @@
1
+ import { defaultFuncParams } from './code-editor-helper.mocks';
2
+ import { CodeEditorPhpHelper } from './php-helper';
3
+
4
+ describe('CodeEditorPhpHelper', () => {
5
+ let helper: CodeEditorPhpHelper;
6
+
7
+ const defaultParams = { ...defaultFuncParams };
8
+ const paramsList = '$param1, $param2, $param3, $param4, $param5, $param6, $param7, $param8';
9
+ const correctFuncOpening = `<?php function mockFunction(${paramsList}) {\n`;
10
+ const correctInitCode = `${correctFuncOpening}\t //Insert your code here \n}\n ?>`;
11
+
12
+ beforeEach(() => {
13
+ helper = new CodeEditorPhpHelper(defaultParams);
14
+ });
15
+
16
+ describe('when getting init code', () => {
17
+ let result: string;
18
+
19
+ beforeEach(() => {
20
+ result = helper.getInitCode();
21
+ });
22
+
23
+ it('should return proper init code', () => {
24
+ expect(result).toEqual(correctInitCode);
25
+ });
26
+ });
27
+
28
+ describe('when getting func opening', () => {
29
+ let result: string;
30
+
31
+ beforeEach(() => {
32
+ result = helper.getFunctionOpening();
33
+ });
34
+
35
+ it('should return proper func opening', () => {
36
+ expect(result).toEqual(correctFuncOpening);
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,32 @@
1
+ import { CodeEditorHelperBase } from './code-editor-helper.base';
2
+ import { CodeEditorFuncOptions, CodeEditorHelper, CodeEditorLanguages } from './code-editor-helper.model';
3
+
4
+ export class CodeEditorPhpHelper extends CodeEditorHelperBase implements CodeEditorHelper {
5
+ language = CodeEditorLanguages.Php;
6
+
7
+ constructor(private functionOptions: CodeEditorFuncOptions) {
8
+ super();
9
+ }
10
+
11
+ getInitCode(): string {
12
+ return `${this.getFunctionOpening()}\t //Insert your code here \n}\n ?>`;
13
+ }
14
+
15
+ getFunctionOpening(): string {
16
+ const { name: funcName } = this.functionOptions;
17
+
18
+ return `<?php function ${funcName}(${this.getParamsString()}) {\n`;
19
+ }
20
+
21
+ private getParamsString(): string {
22
+ const { params } = this.functionOptions;
23
+ let paramsString = '';
24
+
25
+ if (params && params.length > 0) {
26
+ params.forEach(values => (paramsString += `$${values.name}, `));
27
+ paramsString = paramsString.slice(0, -2);
28
+ }
29
+
30
+ return paramsString;
31
+ }
32
+ }
@@ -0,0 +1,39 @@
1
+ import { defaultFuncParams } from './code-editor-helper.mocks';
2
+ import { CodeEditorPythonHelper } from './python-helper';
3
+
4
+ describe('CodeEditorPythonHelper', () => {
5
+ let helper: CodeEditorPythonHelper;
6
+
7
+ const defaultParams = { ...defaultFuncParams };
8
+ const paramsList = 'param1, param2, param3, param4, param5, param6, param7, param8';
9
+ const correctFuncOpening = `def mockFunction(${paramsList}): \n`;
10
+ const correctInitCode = `${correctFuncOpening}\t #Insert your code here \n`;
11
+
12
+ beforeEach(() => {
13
+ helper = new CodeEditorPythonHelper(defaultParams);
14
+ });
15
+
16
+ describe('when getting init code', () => {
17
+ let result: string;
18
+
19
+ beforeEach(() => {
20
+ result = helper.getInitCode();
21
+ });
22
+
23
+ it('should return proper init code', () => {
24
+ expect(result).toEqual(correctInitCode);
25
+ });
26
+ });
27
+
28
+ describe('when getting func opening', () => {
29
+ let result: string;
30
+
31
+ beforeEach(() => {
32
+ result = helper.getFunctionOpening();
33
+ });
34
+
35
+ it('should return proper func opening', () => {
36
+ expect(result).toEqual(correctFuncOpening);
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,32 @@
1
+ import { CodeEditorHelperBase } from './code-editor-helper.base';
2
+ import { CodeEditorFuncOptions, CodeEditorHelper, CodeEditorLanguages } from './code-editor-helper.model';
3
+
4
+ export class CodeEditorPythonHelper extends CodeEditorHelperBase implements CodeEditorHelper {
5
+ language = CodeEditorLanguages.Python;
6
+
7
+ constructor(private functionOptions: CodeEditorFuncOptions) {
8
+ super();
9
+ }
10
+
11
+ getInitCode(): string {
12
+ return `${this.getFunctionOpening()}\t #Insert your code here \n`;
13
+ }
14
+
15
+ getFunctionOpening(): string {
16
+ const { name: funcName } = this.functionOptions;
17
+
18
+ return `def ${funcName}(${this.getParamsString()}): \n`;
19
+ }
20
+
21
+ private getParamsString(): string {
22
+ const { params } = this.functionOptions;
23
+ let paramsString = '';
24
+
25
+ if (params && params.length > 0) {
26
+ params.forEach(values => (paramsString += `${values.name}, `));
27
+ paramsString = paramsString.slice(0, -2);
28
+ }
29
+
30
+ return paramsString;
31
+ }
32
+ }
@@ -0,0 +1,39 @@
1
+ import { defaultFuncParams } from './code-editor-helper.mocks';
2
+ import { CodeEditorRHelper } from './r-helper';
3
+
4
+ describe('CodeEditorRHelper', () => {
5
+ let helper: CodeEditorRHelper;
6
+
7
+ const defaultParams = { ...defaultFuncParams };
8
+ const paramsList = 'param1, param2, param3, param4, param5, param6, param7, param8';
9
+ const correctFuncOpening = `mockFunction <- function(${paramsList}) {\n`;
10
+ const correctInitCode = `${correctFuncOpening}\t #Insert your code here \n}`;
11
+
12
+ beforeEach(() => {
13
+ helper = new CodeEditorRHelper(defaultParams);
14
+ });
15
+
16
+ describe('when getting init code', () => {
17
+ let result: string;
18
+
19
+ beforeEach(() => {
20
+ result = helper.getInitCode();
21
+ });
22
+
23
+ it('should return proper init code', () => {
24
+ expect(result).toEqual(correctInitCode);
25
+ });
26
+ });
27
+
28
+ describe('when getting func opening', () => {
29
+ let result: string;
30
+
31
+ beforeEach(() => {
32
+ result = helper.getFunctionOpening();
33
+ });
34
+
35
+ it('should return proper func opening', () => {
36
+ expect(result).toEqual(correctFuncOpening);
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,32 @@
1
+ import { CodeEditorHelperBase } from './code-editor-helper.base';
2
+ import { CodeEditorFuncOptions, CodeEditorHelper, CodeEditorLanguages } from './code-editor-helper.model';
3
+
4
+ export class CodeEditorRHelper extends CodeEditorHelperBase implements CodeEditorHelper {
5
+ language = CodeEditorLanguages.R;
6
+
7
+ constructor(private functionOptions: CodeEditorFuncOptions) {
8
+ super();
9
+ }
10
+
11
+ getInitCode(): string {
12
+ return `${this.getFunctionOpening()}\t #Insert your code here \n}`;
13
+ }
14
+
15
+ getFunctionOpening(): string {
16
+ const { name: funcName } = this.functionOptions;
17
+
18
+ return `${funcName} <- function(${this.getParamsString()}) {\n`;
19
+ }
20
+
21
+ private getParamsString(): string {
22
+ const { params } = this.functionOptions;
23
+ let paramsString = '';
24
+
25
+ if (params && params.length > 0) {
26
+ params.forEach(values => (paramsString += `${values.name}, `));
27
+ paramsString = paramsString.slice(0, -2);
28
+ }
29
+
30
+ return paramsString;
31
+ }
32
+ }
@@ -0,0 +1,39 @@
1
+ import { defaultFuncParams } from './code-editor-helper.mocks';
2
+ import { CodeEditorRubyHelper } from './ruby-helper';
3
+
4
+ describe('CodeEditorRubyHelper', () => {
5
+ let helper: CodeEditorRubyHelper;
6
+
7
+ const defaultParams = { ...defaultFuncParams };
8
+ const paramsList = 'param1, param2, param3, param4, param5, param6, param7, param8';
9
+ const correctFuncOpening = `def mockFunction(${paramsList})\n`;
10
+ const correctInitCode = `${correctFuncOpening}\t #Insert your code here \nend`;
11
+
12
+ beforeEach(() => {
13
+ helper = new CodeEditorRubyHelper(defaultParams);
14
+ });
15
+
16
+ describe('when getting init code', () => {
17
+ let result: string;
18
+
19
+ beforeEach(() => {
20
+ result = helper.getInitCode();
21
+ });
22
+
23
+ it('should return proper init code', () => {
24
+ expect(result).toEqual(correctInitCode);
25
+ });
26
+ });
27
+
28
+ describe('when getting func opening', () => {
29
+ let result: string;
30
+
31
+ beforeEach(() => {
32
+ result = helper.getFunctionOpening();
33
+ });
34
+
35
+ it('should return proper func opening', () => {
36
+ expect(result).toEqual(correctFuncOpening);
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,32 @@
1
+ import { CodeEditorHelperBase } from './code-editor-helper.base';
2
+ import { CodeEditorFuncOptions, CodeEditorHelper, CodeEditorLanguages } from './code-editor-helper.model';
3
+
4
+ export class CodeEditorRubyHelper extends CodeEditorHelperBase implements CodeEditorHelper {
5
+ language = CodeEditorLanguages.Ruby;
6
+
7
+ constructor(private functionOptions: CodeEditorFuncOptions) {
8
+ super();
9
+ }
10
+
11
+ getInitCode(): string {
12
+ return `${this.getFunctionOpening()}\t #Insert your code here \nend`;
13
+ }
14
+
15
+ getFunctionOpening(): string {
16
+ const { name: funcName } = this.functionOptions;
17
+
18
+ return `def ${funcName}(${this.getParamsString()})\n`;
19
+ }
20
+
21
+ private getParamsString(): string {
22
+ const { params } = this.functionOptions;
23
+ let paramsString = '';
24
+
25
+ if (params && params.length > 0) {
26
+ params.forEach(values => (paramsString += `${values.name}, `));
27
+ paramsString = paramsString.slice(0, -2);
28
+ }
29
+
30
+ return paramsString;
31
+ }
32
+ }
@@ -0,0 +1,41 @@
1
+ import { defaultFuncParams } from './code-editor-helper.mocks';
2
+ import { CodeEditorScalaHelper } from './scala-helper';
3
+
4
+ describe('CodeEditorScalaHelper', () => {
5
+ let helper: CodeEditorScalaHelper;
6
+
7
+ const defaultParams = { ...defaultFuncParams };
8
+ const paramsList =
9
+ 'param1: Boolean, param2: Int, param3: Double, param4: Float, param5: String, param6: Array[Boolean], param7: Array[Integer], param8: Array[Float]';
10
+ const packages = 'package Testgorilla\nobject TestTaker\n';
11
+ const correctFuncOpening = `def mockFunction(${paramsList}) : Boolean = {\n`;
12
+ const correctInitCode = `${packages}${correctFuncOpening}\t //Insert your code here \n}`;
13
+
14
+ beforeEach(() => {
15
+ helper = new CodeEditorScalaHelper(defaultParams);
16
+ });
17
+
18
+ describe('when getting init code', () => {
19
+ let result: string;
20
+
21
+ beforeEach(() => {
22
+ result = helper.getInitCode();
23
+ });
24
+
25
+ it('should return proper init code', () => {
26
+ expect(result).toEqual(correctInitCode);
27
+ });
28
+ });
29
+
30
+ describe('when getting func opening', () => {
31
+ let result: string;
32
+
33
+ beforeEach(() => {
34
+ result = helper.getFunctionOpening();
35
+ });
36
+
37
+ it('should return proper func opening', () => {
38
+ expect(result).toEqual(correctFuncOpening);
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,53 @@
1
+ import { CodeEditorHelperBase } from './code-editor-helper.base';
2
+ import {
3
+ CodeEditorFuncOptions,
4
+ CodeEditorHelper,
5
+ CodeEditorLanguages,
6
+ CodeEditorTypesMap,
7
+ } from './code-editor-helper.model';
8
+
9
+ export class CodeEditorScalaHelper extends CodeEditorHelperBase implements CodeEditorHelper {
10
+ language = CodeEditorLanguages.Scala;
11
+ typesMap: CodeEditorTypesMap = {
12
+ boolean: 'Boolean',
13
+ int: 'Int',
14
+ double: 'Double',
15
+ float: 'Float',
16
+ str: 'String',
17
+ array_boolean: 'Array[Boolean]',
18
+ array_int: 'Array[Integer]',
19
+ array_float: 'Array[Float]',
20
+ array_double: 'Array[Double]',
21
+ array_str: 'Array[String]',
22
+ };
23
+
24
+ private packagesText = 'package Testgorilla\nobject TestTaker\n';
25
+
26
+ constructor(private functionOptions: CodeEditorFuncOptions) {
27
+ super();
28
+ }
29
+
30
+ getInitCode(): string {
31
+ return `${this.packagesText}${this.getFunctionOpening()}\t //Insert your code here \n}`;
32
+ }
33
+
34
+ getFunctionOpening(): string {
35
+ const { name: funcName, returnType } = this.functionOptions;
36
+ const params = this.getParamsString();
37
+ const showingReturnType = this.parseType(returnType);
38
+
39
+ return `def ${funcName}(${params}) : ${showingReturnType} = {\n`;
40
+ }
41
+
42
+ private getParamsString(): string {
43
+ const { params } = this.functionOptions;
44
+ let paramsString = '';
45
+
46
+ if (params && params.length > 0) {
47
+ params.forEach(values => (paramsString += `${values.name}: ${this.parseType(values.type)}, `));
48
+ paramsString = paramsString.slice(0, -2);
49
+ }
50
+
51
+ return paramsString;
52
+ }
53
+ }