mirror of
https://github.com/gramps-project/gramps-web.git
synced 2026-04-18 05:08:34 -04:00
* 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
29 lines
674 B
JavaScript
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'})
|
|
})
|
|
})
|
|
})
|