Skip to content

Commit f5f4f15

Browse files
committed
Start unit testing code snippet contents service
1 parent 303cda5 commit f5f4f15

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { CodeSnippetContentsService } from '../src/CodeSnippetContentsService';
2+
3+
const codeSnippetContentsService = CodeSnippetContentsService.getInstance();
4+
5+
test('test getData', () => {
6+
const res = {
7+
name: 'sum_array',
8+
description:
9+
'Scala program of array. Declare, print, and calculate sum of all elements.',
10+
language: 'Scala',
11+
code: [
12+
'object ExampleArray1 {',
13+
' ',
14+
' def main(args: Array[String]) {',
15+
' ',
16+
' var numbers = Array(10,20,30,40,50);',
17+
' var N:Int=0;',
18+
' ',
19+
' //print all array elements',
20+
' println("All array elements: ");',
21+
' for ( N <- numbers ) {',
22+
' println(N);',
23+
' }',
24+
' //calculating SUM of all elements',
25+
' var sum: Int=0;',
26+
' for ( N <- numbers ) {',
27+
' sum+=N;',
28+
' } ',
29+
' println("Sum of all array elements: "+sum);',
30+
'',
31+
' }',
32+
'}'
33+
],
34+
id: 11,
35+
tags: ['math']
36+
};
37+
const data = codeSnippetContentsService.getData(
38+
'snippets/sum_array.json',
39+
'file'
40+
);
41+
42+
data.then(val => expect(val).toBe(res));
43+
});

0 commit comments

Comments
 (0)