How to use the kitsu function in kitsu

To help you get started, we’ve selected a few kitsu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wopian / kitsu / packages / kitsu / src / index.spec.js View on Github external
it('does not convert resource requests if resourceCase option is \'none\'', () => {
      expect.assertions(3)
      const api = new Kitsu({
        resourceCase: 'none'
      })
      expect(api.resCase('long-word')).toBe('long-word')
      expect(api.resCase('long_word')).toBe('long_word')
      expect(api.resCase('longWord')).toBe('longWord')
    })
github wopian / kitsu / packages / kitsu / src / index.spec.js View on Github external
it('uses Kitsu.io\'s API by default', () => {
      expect.assertions(1)
      const api = new Kitsu()
      expect(api.axios.defaults.baseURL).toBe('https://kitsu.io/api/edge')
    })
github wopian / kitsu / packages / kitsu / src / index.spec.js View on Github external
it('sets additional headers', () => {
      expect.assertions(1)
      const api = new Kitsu()
      api.headers.Key = 'value'
      expect(api.headers.Key).toBe('value')
    })
github wopian / kitsu / packages / kitsu / src / index.spec.js View on Github external
describe('method aliases', () => {
    const api = new Kitsu()

    it('aliases fetch to get', () => {
      expect.assertions(1)
      expect(api.fetch).toEqual(api.get)
    })

    it('aliases update to patch', () => {
      expect.assertions(1)
      expect(api.update).toEqual(api.patch)
    })

    it('aliases create to post', () => {
      expect.assertions(1)
      expect(api.create).toEqual(api.post)
    })
github wopian / kitsu / packages / kitsu / src / isAuth.spec.js View on Github external
it('should return false if Authorization header not set', () => {
    expect.assertions(1)
    const api = new Kitsu()
    expect(api.isAuth).toBe(false)
  })
github wopian / kitsu / packages / kitsu / src / index.spec.js View on Github external
it('does not convert types into camelCase if camelCaseTypes option is false', () => {
      expect.assertions(3)
      const api = new Kitsu({
        camelCaseTypes: false
      })
      expect(api.camel('long-word')).toBe('long-word')
      expect(api.camel('long_word')).toBe('long_word')
      expect(api.camel('longWord')).toBe('longWord')
    })
github wopian / kitsu / src / methods / whoAmI.spec.js View on Github external
it('should throw an error if not logged in', async () => {
    expect.assertions(1)
    try {
      const kitsu = new Kitsu()
      await kitsu.whoAmI()
    } catch (e) {
      expect(e.message).toEqual('Not authenticated')
    }
  })
})
github wopian / kitsu / packages / kitsu / src / isAuth.spec.js View on Github external
it('should return true if Authorization header is set by method', () => {
    expect.assertions(1)
    const api = new Kitsu()
    api.headers['Authorization'] = 'value'
    expect(api.isAuth).toBe(true)
  })
})
github wopian / kitsu / packages / kitsu / src / post.spec.js View on Github external
it('sends headers', async done => {
      expect.assertions(1)
      const api = new Kitsu({ headers: { Authorization: true } })
      mock.onPost('/anime').reply(config => {
        expect(config.headers).toEqual({
          Accept: 'application/vnd.api+json',
          'Content-Type': 'application/vnd.api+json',
          Authorization: true,
          extra: true
        })
        return [ 200 ]
      })
      api.post('anime', { id: '1', type: 'anime' }, { extra: true }).catch(err => {
        done.fail(err)
      })
      done()
    })
github wopian / kitsu / packages / kitsu / src / index.spec.js View on Github external
it('uses pluralize by default', () => {
      expect.assertions(2)
      const api = new Kitsu()
      expect(api.plural).toEqual(pluralize)
      expect(api.plural('apple')).toBe('apples')
    })