From a73c433cfc448b08ff534a608154120f4944d9e4 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Tue, 31 Jul 2018 18:41:14 -0300 Subject: [PATCH] wip --- server/graphql/graphql_test.go | 77 ++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/server/graphql/graphql_test.go b/server/graphql/graphql_test.go index 1de49eb6..7643f7f1 100644 --- a/server/graphql/graphql_test.go +++ b/server/graphql/graphql_test.go @@ -1049,6 +1049,83 @@ func TestMutations(t *testing.T) { }, } + m.On("Update", oUpdated).Once(). + Return(oUpdated, nil) + + return m + }(), + }, + "organizationUpdate/without_complement": testCase{ + token: dToken, + mutation: `mutation { + viewer { + organizationUpdate(input: { + name: "new name", + address: { + withoutComplement: true + } + }) { + organization { + name, address {complement} + } + } + } + }`, + response: `{"data":{"viewer":{"organizationUpdate":{"organization":{ + "id" : 1,"name": "new name", "about": "old about", "phone": "", + "video": "http://video.com/wv", "email": "org@org.org", + "address" : { + "street": "Rua Algum Lugar (Nova)", "number": "500", + "neighbordhood": "Algum Bairro Antigo", "city": "Curitiba", + "state": "PR", "zipcode": "90230000", "complement": "Perto do Obelisco" + } + }}}}}`, + orgRepoMock: func() *orgRepoMock { + m := &orgRepoMock{} + m.On("Get", int64(1)).Once(). + Return( + &model.Organization{ + User: model.User{ + ID: 1, + Email: "org@org.org", + }, + Name: "old name", + About: "old about", + Phone: "", + Video: "http://video.com/wv", + Address: model.Address{ + Street: "Rua Algum Lugar", + Number: "500", + Neighborhood: "Algum Bairro Antigo", + City: "Curitiba", + State: "PR", + Zipcode: "90230000", + Complement: nulls.NewString("Perto do Obelisco"), + }, + }, + nil, + ) + + oUpdated := model.Organization{ + User: model.User{ + ID: 1, + Email: "org@org.org", + }, + Name: "new name", + About: "old about", + Phone: "", + Video: "http://video.com/wv", + Address: model.Address{ + Street: "Rua Algum Lugar (Nova)", + Number: "500", + Neighborhood: "Algum Bairro Antigo", + City: "Curitiba", + State: "PR", + Zipcode: "90230000", + Complement: nulls.NewString("Perto do Obelisco"), + }, + } + m.On("Update", oUpdated).Once(). Return(oUpdated, nil)