Completed
Pull Request — master (#1431)
by Abdeali
01:38
created

bears.tests.js.JSONFormatBearTest.test_sorting()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 6
rs 9.4285
1
from bears.js.JSONFormatBear import JSONFormatBear
2
from bears.tests.LocalBearTestHelper import verify_local_bear
3
4
5
test_file1 = """{
6
    "a": 5,
7
    "b": 5
8
}""".split("\n")
9
10
11
test_file2 = """{
12
    "b": 5,
13
    "a": 5
14
}""".split("\n")
15
16
test_file3 = """{
17
   "b": 5,
18
   "a": 5
19
}""".split("\n")
20
21
22
JSONFormatBear1Test = verify_local_bear(JSONFormatBear,
23
                                        valid_files=(test_file1, test_file2),
24
                                        invalid_files=(test_file3,
25
                                                       [""],
26
                                                       ["random stuff"],
27
                                                       ['{"a":5,"b":5}']))
28
29
30
JSONFormatBear2Test = verify_local_bear(JSONFormatBear,
31
                                        valid_files=(test_file1,),
32
                                        invalid_files=(test_file2,),
33
                                        settings={"json_sort": "true"})
34
35
36
JSONFormatBear3Test = verify_local_bear(JSONFormatBear,
37
                                        valid_files=(test_file3,),
38
                                        invalid_files=(test_file2),
39
                                        settings={"tab_width": "3"})
40