import { expect } from "../test-helper" ; import { JSORMBase , Model , Scope , attr } from "../../src/index" ; import { WhereClause , SortScope , FieldScope , FieldArg , IncludeScope , StatsScope } from "../../src/scope" ; import { RecordProxy } from "../../src/proxies/record-proxy" ; import { CollectionProxy } from "../../src/proxies/collection-proxy" ; @ Model ( ) class ClassBasedRoot extends JSORMBase { } const ExtendBasedRoot = JSORMBase . extend ( { attrs : { stringProp : attr ( { type : String } ) } } ) ; describe ( "Model Class static attributes typings" , ( ) => { ; [ { RootClass : ClassBasedRoot , name : "Class-Based" } , { RootClass : ExtendBasedRoot , name : "extend()-Based" } ] . forEach ( ( { RootClass , name } ) => { describe ( name , ( ) => { describe ( "configuration options" , ( ) => { it ( "has the correct types" , ( ) => { const baseUrl = RootClass . baseUrl ; const apiNamespace = RootClass . apiNamespace ; const jsonapiType = RootClass . jsonapiType ; const endpoint = RootClass . endpoint ; const jwt = RootClass . jwt ; const jwtLocalStorage = RootClass . jwtLocalStorage ; const keyCase = RootClass . keyCase ; const strictAttributes = RootClass . strictAttributes ; } ) ; } ) ; const strEnum = < T extends string > ( o ) : { [ K in T ] : K ; } => { return o . reduce ( ( res , key ) => { res [ key ] = key ; return res ; } , Object . create ( null ) ) ; } ; describe ( "Scope delegators" , ( ) => { it ( "understands all of the scope delegator methods" , ( ) => { const page = RootClass . page ; const per = RootClass . per ; const where = RootClass . where ; const order = RootClass . order ; const select = RootClass . select ; const selectExtra = RootClass . selectExtra ; const includes = RootClass . includes ; const merge = RootClass . merge ; const stats = RootClass . stats ; } ) ; it ( "understands the scope finder methods" , ( ) => { const first = RootClass . first ; const find = RootClass . find ; const all = RootClass . all ; const result = new ExtendBasedRoot ( ) ; result . stringProp = "foo" ; } ) ; } ) ; } ) ; } ) ; } ) ;