nandi/frqpublic Fork 0
284b59c6810a1b2abace25c071e9d166cd0dafc9
Commits
Clone
git clone https://git.rickub.com/nandi/frq.git
git clone ssh://git@rickub.com/nandi/frq.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

tcells.nim · 62 lines · 2.0 KBNim Blame HistoryRaw
Four screens, in Nim c69a09b nandi 18h ago1## The state record, and the few questions it answers itself.
2
3import std/[tables, unittest]
4import frq/[cells, model]
5
6suite "initState":
7 test "starts on the connect screen, not connected":
8 let s = initState()
9 check s.screen == scConnect
10 check s.status == "Not connected"
11 check not s.connecting
12
13 test "the form is filled in with the defaults the screen shows":
14 let s = initState()
15 check s.formHost == defaultHost
16 check s.formPort == defaultPort
17 check s.formTls
18 check s.formNick == "frq-guest"
19 check s.authMode == amGuest
20
21 test "at-present, because a fresh conversation is at its end":
22 check initState().atPresent
23
24 test "nothing is attached, replied to or being edited":
25 let s = initState()
26 check not s.attachment.has
27 check not s.replyingTo.has
28 check not s.editing.has
29 check not s.lightbox.has
30
31suite "wide":
32 test "a phone-width window is not wide":
33 var s = initState(); s.windowWidth = 420
34 check not s.wide
35 test "past wideWidth it is":
36 var s = initState(); s.windowWidth = wideWidth
37 check s.wide
38 test "a window that has not reported yet is not":
39 # windowWidth starts at 0, and guessing wide would put a 320pt list beside
40 # a conversation on a phone.
41 check not initState().wide
42
43suite "currentRoom":
44 test "the room `current` names":
45 var s = initState()
46 s.rooms["#test"] = initRoom("#test")
47 s.current = "#test"
48 check s.currentRoom.name == "#test"
49
50 test "an empty room where nothing is current":
51 # A value rather than an Option: every screen that asks is about to read
52 # `.messages`, and an empty list is the honest answer for "no room".
53 check initState().currentRoom.name == ""
54
55 test "an empty room where `current` names one that is gone":
56 var s = initState(); s.current = "#vanished"
57 check s.currentRoom.name == ""
58
59suite "the constants the screens share":
60 test "popular channels are the discover list":
61 check popularChannels.len == 6
62 check popularChannels[0][0] == "#general"