New view to see available editions from inventaire
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package inventaire
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -53,3 +54,56 @@ func TestCallInventaireBook_BraveNewWorld(t *testing.T) {
|
||||
assert.Equal(t, "Aldous Huxley", result.Author.Name)
|
||||
assert.Equal(t, "écrivain, romancier et philosophe britannique (1894–1963)", result.Author.Description)
|
||||
}
|
||||
|
||||
func TestCallInventaireEdition_TestLimit(t *testing.T) {
|
||||
result, err := CallInventaireEdition("wd:Q339761", "fr", 10, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.Equal(t, int64(34), result.Count)
|
||||
assert.Equal(t, 10, len(result.Results))
|
||||
}
|
||||
|
||||
func TestCallInventaireEdition_TestOffset(t *testing.T) {
|
||||
result, err := CallInventaireEdition("wd:Q3213142", "fr", 0, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.Equal(t, 3, len(result.Results))
|
||||
sortedResults := result.Results
|
||||
sort.Slice(sortedResults, func(i, j int) bool {
|
||||
return sortedResults[i].Id > sortedResults[j].Id
|
||||
})
|
||||
|
||||
assert.Equal(t,
|
||||
InventaireEditionResultBook{
|
||||
Id: "isbn:9782072525216",
|
||||
Title: "La théorie de l'information",
|
||||
ISBN: "978-2-07-252521-6",
|
||||
ReleaseDate: "",
|
||||
Image: "https://inventaire.io/img/entities/fac578440d9bf7afc7f4c5698aa618b8a4d80d21",
|
||||
Lang: "fr",
|
||||
},
|
||||
result.Results[0])
|
||||
assert.Equal(t,
|
||||
InventaireEditionResultBook{
|
||||
Id: "isbn:9782070456260",
|
||||
Title: "La théorie de l'information",
|
||||
ISBN: "978-2-07-045626-0",
|
||||
ReleaseDate: "2014",
|
||||
Image: "https://inventaire.io/img/entities/5044c2265cc42675ac4335387aef189862cbeec1",
|
||||
Lang: "fr",
|
||||
},
|
||||
result.Results[1])
|
||||
assert.Equal(t,
|
||||
InventaireEditionResultBook{
|
||||
Id: "isbn:9782070138098",
|
||||
Title: "La théorie de l'information",
|
||||
ISBN: "978-2-07-013809-8",
|
||||
Publisher: "Éditions Gallimard",
|
||||
ReleaseDate: "2012",
|
||||
Image: "https://inventaire.io/img/entities/a7b9d05c041b98e98c2f429e11cb2b424d78223b",
|
||||
Lang: "fr",
|
||||
},
|
||||
result.Results[2])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user