Files
gramps-web/test/api.test.js
David Straub 909c76cd49 Fix linting and formatting (fixes #86) (#93)
* Update eslint config

* Add vscode

* Remove eslintrc

* npm run format

* Fix some linter errors

* Fix more linter error

* More lint fixes

* Remove stories

* Fix lint error in test

* Fix lint errors in tests

* lint error in test

* Fix more linter errors

* test

* test

* test

* Remove semi

* Remove bracket space

* remove

* Remove semi

* Fix more lint errors

* Fix more lint errors

* Fix remaining lints

* Fix remaining lint issues

* Format

* Add unit test workflow

* Fix wrong import
2022-08-28 14:50:37 +02:00

29 lines
674 B
JavaScript

import fetchMock from 'fetch-mock/esm/client'
import {expect} from '@open-wc/testing'
import {apiGet} from '../src/api.js'
describe('API', () => {
beforeEach(() => {
fetchMock.get('http://myapi:1234/api/my-endpoint', {hello: 'world'})
fetchMock.post('http://myapi:1234/api/token/', {token: 'world'})
})
afterEach(() => {
fetchMock.restore()
})
describe('Test API GET', () => {
it('API get dummy test', async () => {
const data = await apiGet(
'http://myapi:1234',
null,
null,
'/api/my-endpoint'
)
expect(fetchMock.called()).to.be.true
expect(data).to.eql({hello: 'world'})
})
})
})