This repository has been archived by the owner on Dec 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: Update jest settings * test: Update components tests * test: Update utils tests * chore: Remove unused deps * ci: Skipping Node 6
- Loading branch information
Showing
10 changed files
with
156 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ notifications: | |
node_js: | ||
- '9' | ||
- '8' | ||
- '6' | ||
|
||
script: yarn test --coverage && yarn build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
/* eslint-disable react/destructuring-assignment */ | ||
/* eslint-disable react/prop-types */ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { render, cleanup } from 'react-testing-library'; | ||
import { OauthSender } from './index'; | ||
import { buildURL } from '../utils'; | ||
|
||
afterEach(cleanup); | ||
|
||
test('Component: <OauthSender />', () => { | ||
const props = { | ||
authorizeUrl: 'https://www.service.com/oauth2/authorize', | ||
clientId: 'abc', | ||
redirectUri: 'https://www.test.com/redirect', | ||
render: ( | ||
{ url }, // eslint-disable-line | ||
) => ( | ||
<a className="link" href={url}> | ||
render: ({ url }) => ( | ||
<a data-testid="link" href={url}> | ||
Connect | ||
</a> | ||
), | ||
}; | ||
|
||
const wrapper = shallow(<OauthSender {...props} />); | ||
const expectedUrl = buildURL(`${props.authorizeUrl}`, { | ||
const { getByTestId } = render(<OauthSender {...props} />); | ||
|
||
const expectedUrl = buildURL(props.authorizeUrl, { | ||
client_id: props.clientId, | ||
redirect_uri: props.redirectUri, | ||
response_type: 'code', | ||
}); | ||
|
||
expect(wrapper.find('.link').prop('href')).toEqual(expectedUrl); | ||
expect(getByTestId('link')).toHaveAttribute('href', expectedUrl); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,14 @@ | ||
import nock from 'nock'; | ||
import * as utils from './index'; | ||
|
||
beforeAll(() => { | ||
const api = nock('https://api.github.com/'); | ||
|
||
api.get('/users/octocat').reply(200, { | ||
login: 'octocat', | ||
}); | ||
|
||
api.get('/users/404').reply(404, { | ||
message: 'User 404 not found', | ||
}); | ||
}); | ||
|
||
test('utils.buildURL', () => { | ||
const baseUrl = 'https://www.test.com'; | ||
|
||
let url = utils.buildURL(baseUrl, { | ||
expect(utils.buildURL(baseUrl, { | ||
a: 'hello', | ||
b: 'world', | ||
}); | ||
expect(url).toEqual(`${baseUrl}?a=hello&b=world`); | ||
|
||
url = utils.buildURL(baseUrl); | ||
expect(url).toBe(baseUrl); | ||
|
||
url = utils.buildURL(`${baseUrl}?a=hello`, { b: 'world' }); | ||
expect(url).toBe(`${baseUrl}?a=hello&b=world`); | ||
}); | ||
|
||
test('utils.fetch2', async () => { | ||
const data = await utils.fetch2('https://api.github.com/users/octocat'); | ||
expect(data.login).toBe('octocat'); | ||
})).toEqual(`${baseUrl}?a=hello&b=world`); | ||
|
||
try { | ||
await utils.fetch2('https://api.github.com/users/404'); | ||
expect(true).toBe(false); | ||
} catch (err) { | ||
expect(err.response.ok).toBe(false); | ||
expect(err.message).toBe('Not Found'); | ||
} | ||
expect(utils.buildURL(baseUrl)).toBe(baseUrl); | ||
expect(utils.buildURL(`${baseUrl}?a=hello`, { b: 'world' })).toBe(`${baseUrl}?a=hello&b=world`); | ||
expect(utils.buildURL(baseUrl, {})).toBe(baseUrl); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'jest-dom/extend-expect'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
/* eslint-disable import/first */ | ||
import './raf-polyfill'; | ||
import 'isomorphic-fetch'; | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
configure({ adapter: new Adapter() }); |
Oops, something went wrong.