@@ -656,3 +656,139 @@ avaTest('Resources cannot use only and expect at the same time', (test) => {
656656 } )
657657 } , / Y o u c a n ' t u s e / , 'except and only not throws' )
658658} )
659+
660+ avaTest ( 'Resources with shallow creator with empty options' , ( test ) => {
661+ test . deepEqual (
662+ createRest ( ( root ) => {
663+ root . resources ( 'books' , DefaultController , { } , ( books ) => {
664+ books . get ( 'status' , get )
665+ } )
666+ } ) ,
667+ make ( [ ] , [ ] , { } , {
668+ books : make (
669+ [ DefaultController . beforeEach ] ,
670+ [ DefaultController . afterEach ] ,
671+ {
672+ GET : [ DefaultController . index ] , POST : [ DefaultController . create ] ,
673+ } ,
674+ {
675+ ':bookId' : make ( [ ] , [ ] , {
676+ GET : [ DefaultController . read ] ,
677+ PUT : [ DefaultController . update ] ,
678+ PATCH : [ DefaultController . patch ] ,
679+ DELETE : [ DefaultController . destroy ] ,
680+ } ) ,
681+ status : make ( [ ] , [ ] , {
682+ GET : [ get ] ,
683+ } ) ,
684+ }
685+ ) ,
686+ } )
687+ )
688+ } )
689+
690+ avaTest ( 'Resources with shallow creator instead of options' , ( test ) => {
691+ test . deepEqual (
692+ createRest ( ( root ) => {
693+ root . resources ( 'books' , DefaultController , ( books ) => {
694+ books . get ( 'status' , get )
695+ } )
696+ } ) ,
697+ make ( [ ] , [ ] , { } , {
698+ books : make (
699+ [ DefaultController . beforeEach ] ,
700+ [ DefaultController . afterEach ] ,
701+ {
702+ GET : [ DefaultController . index ] , POST : [ DefaultController . create ] ,
703+ } ,
704+ {
705+ ':bookId' : make ( [ ] , [ ] , {
706+ GET : [ DefaultController . read ] ,
707+ PUT : [ DefaultController . update ] ,
708+ PATCH : [ DefaultController . patch ] ,
709+ DELETE : [ DefaultController . destroy ] ,
710+ } ) ,
711+ status : make ( [ ] , [ ] , {
712+ GET : [ get ] ,
713+ } ) ,
714+ }
715+ ) ,
716+ } )
717+ )
718+ } )
719+
720+ avaTest ( 'Resources with scope:memberId creator' , ( test ) => {
721+ test . deepEqual (
722+ createRest ( ( root ) => {
723+ root . resources ( 'books' , DefaultController , { } , ( books ) => {
724+ books . get ( 'status' , get )
725+ books . scope ( ':bookId' , ( bookId ) => {
726+ bookId . get ( 'details' , get )
727+ } )
728+ } )
729+ } ) ,
730+ make ( [ ] , [ ] , { } , {
731+ books : make (
732+ [ DefaultController . beforeEach ] ,
733+ [ DefaultController . afterEach ] ,
734+ {
735+ GET : [ DefaultController . index ] , POST : [ DefaultController . create ] ,
736+ } ,
737+ {
738+ ':bookId' : make ( [ ] , [ ] ,
739+ {
740+ GET : [ DefaultController . read ] ,
741+ PUT : [ DefaultController . update ] ,
742+ PATCH : [ DefaultController . patch ] ,
743+ DELETE : [ DefaultController . destroy ] ,
744+ } ,
745+ {
746+ details : make ( [ ] , [ ] , { GET : [ get ] } ) ,
747+ }
748+ ) ,
749+ status : make ( [ ] , [ ] , {
750+ GET : [ get ] ,
751+ } ) ,
752+ }
753+ ) ,
754+ } )
755+ )
756+ } )
757+
758+ avaTest ( 'Resources with memberId creator with renamed memberId' , ( test ) => {
759+ test . deepEqual (
760+ createRest ( ( root ) => {
761+ root . resources ( 'books' , DefaultController , { memberId : 'demoId' } , ( books ) => {
762+ books . get ( 'status' , get )
763+ books . scope ( ':demoId' , ( bookId ) => {
764+ bookId . get ( 'details' , get )
765+ } )
766+ } )
767+ } ) ,
768+ make ( [ ] , [ ] , { } , {
769+ books : make (
770+ [ DefaultController . beforeEach ] ,
771+ [ DefaultController . afterEach ] ,
772+ {
773+ GET : [ DefaultController . index ] , POST : [ DefaultController . create ] ,
774+ } ,
775+ {
776+ ':demoId' : make ( [ ] , [ ] ,
777+ {
778+ GET : [ DefaultController . read ] ,
779+ PUT : [ DefaultController . update ] ,
780+ PATCH : [ DefaultController . patch ] ,
781+ DELETE : [ DefaultController . destroy ] ,
782+ } ,
783+ {
784+ details : make ( [ ] , [ ] , { GET : [ get ] } ) ,
785+ }
786+ ) ,
787+ status : make ( [ ] , [ ] , {
788+ GET : [ get ] ,
789+ } ) ,
790+ }
791+ ) ,
792+ } )
793+ )
794+ } )
0 commit comments