-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathduplication_checker_test.go
61 lines (53 loc) · 1.77 KB
/
duplication_checker_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDuplicatedScriptsCheck(t *testing.T) { // same for colors and long scripts
files := []string{"tests/normal_css.css", "tests/unformatcss.css"}
longScriptList, colorScriptList := []Script{}, []Script{}
for _, file := range files {
longs, colors := SectionsParse(file, 80)
longScriptList = append(longScriptList, longs...)
colorScriptList = append(colorScriptList, colors...)
}
summaryList := DupScriptsChecker(colorScriptList)
assert.Equal(t, len(summaryList), 1)
assert.Equal(t, len(summaryList[0].scripts), 3)
summaryList = DupScriptsChecker(longScriptList)
assert.Equal(t, len(summaryList), 1)
}
func TestDuplicatedStyledComponentsCheck(t *testing.T) {
path := "tests/sample.ts"
longs, colors := SectionsParse(path, 80)
summaryList := DupScriptsChecker(colors)
assert.Equal(t, len(summaryList), 0)
summaryList = DupScriptsChecker(longs)
assert.Equal(t, len(summaryList), 1)
}
func TestDupStyleSectionsChecker(t *testing.T) { //same for css classes
styleSectionFirst := StyleSection{
name: "firstName",
filePath: "tests/firstLocation",
value: []string{"color:'red'", "size:18"},
valueHash: 0x5777296270491287,
}
styleSectionSecond := StyleSection{
name: "secondName",
filePath: "tests/secondLocation",
value: []string{"color:'green'", "size:18"},
valueHash: 0xe29045cf01e7f547,
}
styleSectionThird := StyleSection{
name: "thirdName",
filePath: "tests/thirdLocation",
value: []string{"color:'red'", "size:18"},
valueHash: 0x5777296270491287,
}
styleList := []StyleSection{
styleSectionFirst,
styleSectionSecond,
styleSectionThird}
sectionSummary := DupStyleSectionsChecker(styleList)
assert.Equal(t, 2, sectionSummary[0].count)
}