package Ġio . me how . labor atory Ċ Ċ import Ġapp . cash . tur bine . test Ċ import Ġio . kot est . core . spec . style . Describe Spec Ċ import Ġio . kot est . matchers . shouldBe Ċ Ċ internal Ġclass ĠS ourced Feature Storage Spec Ġ: ĠDescribe Spec ({ ĊĠ Ġlateinit Ġvar Ġlocal L abor atory : ĠLaboratory ĊĠ Ġlateinit Ġvar Ġremote L abor atory A : ĠLaboratory ĊĠ Ġlateinit Ġvar Ġremote L abor atory B : ĠLaboratory ĊĠ Ġlateinit Ġvar Ġs ourced L abor atory : ĠLaboratory ĊĊĠ Ġbefore Test Ġ{ ĊĠĠĠ Ġval ĠlocalStorage Ġ= ĠFeature Storage . in Memory () ĊĠĠĠ Ġval Ġremote Storage A Ġ= ĠFeature Storage . in Memory () ĊĠĠĠ Ġval Ġremote Storage B Ġ= ĠFeature Storage . in Memory () ĊĠĠĠ Ġval Ġs ourced Storage Ġ= ĠS ourced Feature Storage ( ĊĠĠĠĠĠĠĠ ĠlocalStorage , ĊĠĠĠĠĠĠĠ Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Remote A " Ġto Ġremote Storage A , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Remote B " Ġto Ġremote Storage B , ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠ Ġ) ĊĠĠĠ Ġlocal L abor atory Ġ= ĠLaboratory . create ( localStorage ) ĊĠĠĠ Ġremote L abor atory A Ġ= ĠLaboratory . create ( remote Storage A ) ĊĠĠĠ Ġremote L abor atory B Ġ= ĠLaboratory . create ( remote Storage B ) ĊĠĠĠ Ġs ourced L abor atory Ġ= ĠLaboratory . create ( s ourced Storage ) ĊĠ Ġ} ĊĊĠ Ġdescribe (" s ourced Ġfeature Ġstorage ") Ġ{ ĊĠĠĠ Ġcontext (" with Ġno Ġsources Ġset ") Ġ{ ĊĠĠĠĠĠ Ġit (" t akes Ġinitial Ġvalue Ġfrom Ġa Ġdefault Ġsource ") Ġ{ ĊĠĠĠĠĠĠĠ Ġlocal L abor atory . set Option ( First Feature . B ) ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . experiment < First Feature >() ĠshouldBe ĠFirst Feature . B ĊĊĠĠĠĠĠĠĠ Ġremote L abor atory B . set Option ( Second Feature . C ) ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . experiment < Second Feature >() ĠshouldBe ĠSecond Feature . C ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġit (" ob serves Ġchanges Ġof Ġa Ġdefault Ġfeature Ġsource ") Ġ{ ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . observe < Second Feature >(). test Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . A ĊĊĠĠĠĠĠĠĠĠĠ Ġremote L abor atory B . set Option ( Second Feature . B ) ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . B ĊĊĠĠĠĠĠĠĠĠĠ Ġremote L abor atory B . set Option ( Second Feature . C ) ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . C ĊĊĠĠĠĠĠĠĠĠĠ Ġcancel () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġit (" allows Ġto Ġchange Ġa Ġfeature Ġsource ") Ġ{ ĊĠĠĠĠĠ Ġs ourced L abor atory . set Option ( First Feature . Source . Remote A ) ĊĊĠĠĠĠĠ Ġremote L abor atory A . set Option ( First Feature . C ) ĊĠĠĠĠĠ Ġs ourced L abor atory . experiment < First Feature >() ĠshouldBe ĠFirst Feature . C ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġit (" ob serves Ġchanges Ġof Ġa Ġfeature Ġsource ") Ġ{ ĊĠĠĠĠĠ Ġlocal L abor atory . set Option ( Second Feature . A ) ĊĠĠĠĠĠ Ġremote L abor atory A . set Option ( Second Feature . B ) ĊĠĠĠĠĠ Ġremote L abor atory B . set Option ( Second Feature . C ) ĊĊĠĠĠĠĠ Ġs ourced L abor atory . observe < Second Feature >(). test Ġ{ ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . C ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . set Option ( Second Feature . Source . Local ) ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . A ĊĊĠĠĠĠĠĠĠ Ġlocal L abor atory . set Option ( Second Feature . C ) ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . C ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . set Option ( Second Feature . Source . Remote A ) ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . B ĊĊĠĠĠĠĠĠĠ Ġremote L abor atory A . set Option ( Second Feature . A ) ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . A ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . set Option ( Second Feature . Source . Remote B ) ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . C ĊĊĠĠĠĠĠĠĠ Ġremote L abor atory B . set Option ( Second Feature . B ) ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . B ĊĊĠĠĠĠĠĠĠ Ġcancel () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġit (" does Ġnot Ġobserve Ġchanges Ġof Ġdifferent Ġfeature Ġsource ") Ġ{ ĊĠĠĠĠĠ Ġlocal L abor atory . set Option ( Second Feature . B ) ĊĠĠĠĠĠ Ġremote L abor atory A . set Option ( Second Feature . C ) ĊĊĠĠĠĠĠ Ġs ourced L abor atory . observe < Second Feature >(). test Ġ{ ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠSecond Feature . A ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . set Option ( First Feature . Source . Local ) ĊĠĠĠĠĠĠĠ Ġexpect No Events () ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . set Option ( First Feature . Source . Remote A ) ĊĠĠĠĠĠĠĠ Ġexpect No Events () ĊĊĠĠĠĠĠĠĠ Ġcancel () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcontext (" for Ġempty Ġsource ") Ġ{ ĊĠĠĠĠĠ Ġit (" f alls Ġback Ġto Ġob serving Ġa Ġlocal Ġstorage ") Ġ{ ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . observe < Empty Source Feature >(). test Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠEmpty Source Feature . A ĊĊĠĠĠĠĠĠĠĠĠ Ġlocal L abor atory . set Option ( Empty Source Feature . B ) ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠEmpty Source Feature . B ĊĊĠĠĠĠĠĠĠĠĠ Ġcancel () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġit (" f alls Ġback s Ġto Ġexperiment ing Ġwith Ġa Ġlocal Ġstorage ") Ġ{ ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . experiment < Empty Source Feature >() ĠshouldBe ĠEmpty Source Feature . A ĊĊĠĠĠĠĠĠĠ Ġlocal L abor atory . set Option ( Empty Source Feature . C ) ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . experiment < Empty Source Feature >() ĠshouldBe ĠEmpty Source Feature . C ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcontext (" for Ġunknown Ġsource ") Ġ{ ĊĠĠĠĠĠ Ġit (" f alls Ġback Ġto Ġob serving Ġa Ġlocal Ġstorage ") Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠlocalStorage Ġ= ĠFeature Storage . in Memory () ĊĠĠĠĠĠĠĠ Ġval Ġs ourced Storage Ġ= ĠS ourced Feature Storage ( localStorage , Ġempty Map ()) ĊĠĠĠĠĠĠĠ Ġlocal L abor atory Ġ= ĠLaboratory . create ( localStorage ) ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory Ġ= ĠLaboratory . create ( s ourced Storage ) ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . observe < First Feature >(). test Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠFirst Feature . A ĊĊĠĠĠĠĠĠĠĠĠ Ġlocal L abor atory . set Option ( First Feature . B ) ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠFirst Feature . B ĊĊĠĠĠĠĠĠĠĠĠ Ġcancel () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġit (" f alls Ġback s Ġto Ġexperiment ing Ġwith Ġa Ġlocal Ġstorage ") Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠlocalStorage Ġ= ĠFeature Storage . in Memory () ĊĠĠĠĠĠĠĠ Ġval Ġs ourced Storage Ġ= ĠS ourced Feature Storage ( localStorage , Ġempty Map ()) ĊĠĠĠĠĠĠĠ Ġlocal L abor atory Ġ= ĠLaboratory . create ( localStorage ) ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory Ġ= ĠLaboratory . create ( s ourced Storage ) ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . experiment < First Feature >() ĠshouldBe ĠFirst Feature . A ĊĊĠĠĠĠĠĠĠ Ġlocal L abor atory . set Option ( First Feature . C ) ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . experiment < First Feature >() ĠshouldBe ĠFirst Feature . C ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcontext (" for Ġun s ourced Ġfeature ") Ġ{ ĊĠĠĠĠĠ Ġit (" f alls Ġback Ġto Ġob serving Ġa Ġlocal Ġstorage ") Ġ{ ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . observe < Un s ourced Feature >(). test Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠUn s ourced Feature . A ĊĊĠĠĠĠĠĠĠĠĠ Ġlocal L abor atory . set Option ( Un s ourced Feature . B ) ĊĠĠĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠUn s ourced Feature . B ĊĊĠĠĠĠĠĠĠĠĠ Ġcancel () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġit (" f alls Ġback s Ġto Ġexperiment ing Ġwith Ġa Ġlocal Ġstorage ") Ġ{ ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . experiment < Un s ourced Feature >() ĠshouldBe ĠUn s ourced Feature . A ĊĊĠĠĠĠĠĠĠ Ġlocal L abor atory . set Option ( Un s ourced Feature . C ) ĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . experiment < Un s ourced Feature >() ĠshouldBe ĠUn s ourced Feature . C ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġit (" controls Ġlocal Ġfeatures ") Ġ{ ĊĠĠĠĠĠ Ġs ourced L abor atory . observe < First Feature >(). test Ġ{ ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠFirst Feature . A ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . set Option ( First Feature . B ) ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠFirst Feature . B ĊĊĠĠĠĠĠĠĠ Ġs ourced L abor atory . set Option ( First Feature . C ) ĊĠĠĠĠĠĠĠ Ġexpect Item () ĠshouldBe ĠFirst Feature . C ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġit (" clear s Ġonly Ġlocal Ġsource ") Ġ{ ĊĠĠĠĠĠ Ġlocal L abor atory . set Option ( First Feature . B ) ĊĠĠĠĠĠ Ġremote L abor atory A . set Option ( First Feature . B ) ĊĠĠĠĠĠ Ġs ourced L abor atory . set Option ( First Feature . Source . Remote A ) ĊĊĠĠĠĠĠ Ġs ourced L abor atory . clear () ĊĊĠĠĠĠĠ Ġlocal L abor atory . experiment Is ( First Feature . A ) ĊĠĠĠĠĠ Ġremote L abor atory A . experiment Is ( First Feature . B ) ĊĠĠĠĠĠ Ġs ourced L abor atory . experiment Is ( First Feature . A ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ }) Ċ