+ MappingPreview Test
This commit is contained in:
parent
4426b8bc12
commit
7f5d9e9990
1 changed files with 24 additions and 0 deletions
|
|
@ -113,3 +113,27 @@ func TestDataPreviewSimple(t *testing.T) {
|
|||
assert.Equal(t, 1, len(data))
|
||||
assert.Equal(t, 11, len(data[0]))
|
||||
}
|
||||
|
||||
func TestMappingPreviewSimple(t *testing.T) {
|
||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
||||
file := xlsx.Open(simple)
|
||||
defer file.Close()
|
||||
|
||||
imp := Select("order")
|
||||
mapping := imp.MappingPreview(file)
|
||||
assert.Equal(t, true, mapping.AutoMatching)
|
||||
assert.Equal(t, false, mapping.TemplateMatching)
|
||||
assert.Equal(t, 1, mapping.ColStart)
|
||||
assert.Equal(t, 1, mapping.RowStart)
|
||||
assert.Equal(t, 10, len(mapping.Columns))
|
||||
assert.Equal(t, len(imp.Columns), len(mapping.Columns))
|
||||
for i, col := range mapping.Columns {
|
||||
dst := imp.Columns[i].ToMap()
|
||||
assert.Equal(t, dst["name"], col.Field)
|
||||
assert.Equal(t, dst["label"], col.Label)
|
||||
assert.Equal(t, dst["rules"], col.Rules)
|
||||
if col.Field != "remark" {
|
||||
assert.NotEmpty(t, col.Axis)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue