sarala
Version:
Javascript library to communicate with RESTful API built following JSON API specification. inspired by Laravel’s Eloquent.
22 lines (17 loc) • 786 B
JavaScript
import Fool from './dummy/models/Fool'
import Unicorn from './dummy/models/Unicorn'
const initModelLikeAFool = () => {
new Fool()
}
test('it throws error when try to initialize model without resource name', () => {
expect(initModelLikeAFool).toThrow('Sarale: Resource name not defined in Fool model. Implement resourceName method in the Fool model to resolve this error.')
})
test('can call overridable methods of initialize model', () => {
const unicorn = new Unicorn()
expect(unicorn.fields()).toEqual([])
expect(unicorn.dates()).toEqual([])
expect(unicorn.relationships()).toEqual({})
expect(unicorn.computed()).toEqual({})
expect(unicorn.resourceName()).toEqual('unicorns')
expect(unicorn.baseUrl()).toEqual('https://sarala-demo.app/api')
})