diff --git a/desk/lib/contacts/json-1.hoon b/desk/lib/contacts/json-1.hoon index 390f75b8..8837e4ba 100644 --- a/desk/lib/contacts/json-1.hoon +++ b/desk/lib/contacts/json-1.hoon @@ -115,7 +115,7 @@ :: =/ [type=@tas val=json] %. jon - (ot text+(se %tas) value+json ~) + (ot type+(se %tas) value+json ~) ?+ type !! %text %. val (ta %text so) %numb %. val (ta %numb ni) diff --git a/desk/tests/lib/contacts-json-1.hoon b/desk/tests/lib/contacts-json-1.hoon index 5b9cac72..155ec310 100644 --- a/desk/tests/lib/contacts-json-1.hoon +++ b/desk/tests/lib/contacts-json-1.hoon @@ -12,73 +12,187 @@ |= [a=vase b=vase] (expect-eq b a) :: -++ jen-equal +++ enjs-equal |= [jon=json txt=@t] %+ ex-equal !> (en:json:html jon) !> txt :: +++ dejs-equal + |* [saf=$-(json *) txt=@t data=*] + %+ ex-equal + !> (saf (need (de:json:html txt))) + !> data +:: ++ test-ship - %+ jen-equal - (ship:enjs:j ~sampel-palnet) - '"~sampel-palnet"' + ;: weld + %+ enjs-equal + (ship:enjs:j ~sampel-palnet) + '"~sampel-palnet"' + :: + %^ dejs-equal ship:dejs:j + '"~sampel-palnet"' + ~sampel-palnet + == ++ test-cid - %+ jen-equal - (cid:enjs:j 0v11abc) - '"0v11abc"' + ;: weld + %+ enjs-equal + (cid:enjs:j 0v11abc) + '"0v11abc"' + :: + %^ dejs-equal cid:dejs:j + '"0v11abc"' + 0v11abc + == ++ test-kip ;: weld - %+ jen-equal + %+ enjs-equal (kip:enjs:j ~sampel-palnet) '"~sampel-palnet"' :: - %+ jen-equal + %+ enjs-equal (kip:enjs:j id+0v11abc) '"0v11abc"' + :: + %^ dejs-equal kip:dejs:j + '"~sampel-palnet"' + ~sampel-palnet + :: + %^ dejs-equal kip:dejs:j + '"0v11abc"' + id+0v11abc == ++ test-value ;: weld :: - %+ jen-equal - (value:enjs:j text+'the lazy fox') + %+ enjs-equal + (value:enjs:j text+'the lazy fox') '{"type":"text","value":"the lazy fox"}' :: - %+ jen-equal - (value:enjs:j numb+42) + %^ dejs-equal value:dejs:j + '{"type":"text","value":"the lazy fox"}' + text+'the lazy fox' + :: + %+ enjs-equal + (value:enjs:j numb+42) '{"type":"numb","value":42}' :: - %+ jen-equal + %^ dejs-equal value:dejs:j + '{"type":"numb","value":42}' + numb+42 + :: + %+ enjs-equal (value:enjs:j date+~2024.9.11) '{"type":"date","value":"~2024.9.11"}' :: - %+ jen-equal - (value:enjs:j [%tint 0xcafe.babe]) + %^ dejs-equal value:dejs:j + '{"type":"date","value":"~2024.9.11"}' + date+~2024.9.11 + :: + %+ enjs-equal + (value:enjs:j tint+0xcafe.babe) '{"type":"tint","value":"cafe.babe"}' :: - %+ jen-equal - (value:enjs:j [%ship ~sampel-palnet]) + %^ dejs-equal value:dejs:j + '{"type":"tint","value":"cafe.babe"}' + tint+0xcafe.babe + :: + %+ enjs-equal + (value:enjs:j ship+~sampel-palnet) '{"type":"ship","value":"~sampel-palnet"}' :: - %+ jen-equal - (value:enjs:j [%look 'https://ship.io/avatar.png']) + %^ dejs-equal value:dejs:j + '{"type":"ship","value":"~sampel-palnet"}' + ship+~sampel-palnet + :: + %+ enjs-equal + (value:enjs:j look+'https://ship.io/avatar.png') '{"type":"look","value":"https://ship.io/avatar.png"}' :: - %+ jen-equal - (value:enjs:j [%flag [~sampel-palnet %circle]]) + %^ dejs-equal value:dejs:j + '{"type":"look","value":"https://ship.io/avatar.png"}' + look+'https://ship.io/avatar.png' + :: + %+ enjs-equal + (value:enjs:j flag+[~sampel-palnet %circle]) '{"type":"flag","value":"~sampel-palnet/circle"}' :: - %+ jen-equal + %^ dejs-equal value:dejs:j + '{"type":"flag","value":"~sampel-palnet/circle"}' + flag+[~sampel-palnet %circle] + :: + %+ enjs-equal %- value:enjs:j - [%set (silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]])] + set+(silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]]) '{"type":"set","value":[{"type":"flag","value":"~sampel-palnet/circle"},{"type":"flag","value":"~sampel-pardux/square"}]}' + :: + %^ dejs-equal value:dejs:j + '{"type":"set","value":[{"type":"flag","value":"~sampel-palnet/circle"},{"type":"flag","value":"~sampel-pardux/square"}]}' + set+(silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]]) == ++ test-contact - %+ jen-equal - %- contact:enjs:j + ;: weld + %+ enjs-equal + %- contact:enjs:j + %- malt + ^- (list [@tas value]) + :~ name+text/'Sampel' + surname+text/'Palnet' + == + '{"name":{"type":"text","value":"Sampel"},"surname":{"type":"text","value":"Palnet"}}' + :: + %^ dejs-equal contact:dejs:j + '{"name":{"type":"text","value":"Sampel"},"surname":{"type":"text","value":"Palnet"}}' + ^- contact:c %- malt ^- (list [@tas value]) :~ name+text/'Sampel' surname+text/'Palnet' == - '{"name":{"type":"text","value":"Sampel"},"surname":{"type":"text","value":"Palnet"}}' + == +++ test-action + =/ con=contact:c + %- malt + ^- (list [@tas value]) + :~ name+text/'Sampel' + == + =/ mod=contact:c + %- malt + ^- (list [@tas value]) + :~ surname+text/'Palnet' + == + :: + ;: weld + %^ dejs-equal action:dejs:j + '{"anon":null}' + [%anon ~] + :: + %^ dejs-equal action:dejs:j + '{"self":{"name":{"type":"text","value":"Sampel"}}}' + [%self con] + :: + %^ dejs-equal action:dejs:j + '{"page":{"kip":"0v1","contact":{"surname":{"type":"text","value":"Palnet"}}}}' + [%page id+0v1 mod] + :: + %^ dejs-equal action:dejs:j + '{"page":{"kip":"~sampel-palnet","contact":{"surname":{"type":"text","value":"Palnet"}}}}' + [%page ~sampel-palnet mod] + :: + %^ dejs-equal action:dejs:j + '{"wipe":["0v1", "0v2", "~sampel-palnet"]}' + [%wipe id+0v1 id+0v2 ~sampel-palnet ~] + :: + %^ dejs-equal action:dejs:j + '{"meet":["~sampel-palnet", "~master-botnet"]}' + [%meet ~sampel-palnet ~master-botnet ~] + :: + %^ dejs-equal action:dejs:j + '{"drop":["~sampel-palnet", "~master-botnet"]}' + [%drop ~sampel-palnet ~master-botnet ~] + :: + %^ dejs-equal action:dejs:j + '{"snub":["~sampel-palnet", "~master-botnet"]}' + [%snub ~sampel-palnet ~master-botnet ~] + == --