github.com/jordwest/imap-server@v0.0.0-20200627020849-1cf758ba359f/conn/command_list_test.go (about) 1 package conn_test 2 3 import ( 4 "github.com/jordwest/imap-server/conn" 5 . "github.com/onsi/ginkgo" 6 ) 7 8 var _ = Describe("LIST Command", func() { 9 Context("When logged in", func() { 10 BeforeEach(func() { 11 tConn.SetState(conn.StateAuthenticated) 12 tConn.User = mStore.User 13 }) 14 15 It("should return the directory separator", func() { 16 SendLine("abcd.123 LIST \"\" \"\"") 17 ExpectResponse("* LIST (\\Noselect) \"/\" \"\"") 18 ExpectResponse("abcd.123 OK LIST completed") 19 }) 20 21 It("should return the list of mailboxes", func() { 22 SendLine("abcd.123 LIST \"\" \"*\"") 23 ExpectResponse("* LIST () \"/\" \"INBOX\"") 24 ExpectResponse("* LIST () \"/\" \"Trash\"") 25 ExpectResponse("abcd.123 OK LIST completed") 26 }) 27 }) 28 29 Context("When not logged in", func() { 30 BeforeEach(func() { 31 tConn.SetState(conn.StateNotAuthenticated) 32 }) 33 34 It("should give an error", func() { 35 SendLine("abcd.123 LIST \"\" \"*\"") 36 ExpectResponse("abcd.123 BAD not authenticated") 37 }) 38 }) 39 })