forked from auth0/lock
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
148 additions
and
0 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
coverage/ | ||
build/ | ||
css/index.css | ||
lib/ | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ node_js: | |
- '4.2' | ||
script: | ||
- 'npm run test:cli' | ||
- 'npm run test:jest' | ||
env: | ||
- CXX=g++-4.8 | ||
sudo: false | ||
|
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
exports[`AuthButton renders correctly 1`] = ` | ||
<button | ||
className="auth0-lock-social-button auth0-lock-social-big-button" | ||
data-provider="strategy" | ||
disabled={false} | ||
onClick={[Function]} | ||
style={Object {}} | ||
type="button"> | ||
<div | ||
className="auth0-lock-social-button-icon" | ||
style={Object {}} /> | ||
<div | ||
className="auth0-lock-social-button-text" | ||
style={Object {}}> | ||
label | ||
</div> | ||
</button> | ||
`; | ||
|
||
exports[`AuthButton renders when \`big\` is false 1`] = ` | ||
<button | ||
className="auth0-lock-social-button" | ||
data-provider="strategy" | ||
disabled={false} | ||
onClick={[Function]} | ||
style={Object {}} | ||
type="button"> | ||
<div | ||
className="auth0-lock-social-button-icon" | ||
style={Object {}} /> | ||
<div | ||
className="auth0-lock-social-button-text" | ||
style={Object {}}> | ||
label | ||
</div> | ||
</button> | ||
`; | ||
|
||
exports[`AuthButton renders with style customizations 1`] = ` | ||
<button | ||
className="auth0-lock-social-button auth0-lock-social-big-button" | ||
data-provider="strategy" | ||
disabled={false} | ||
onClick={[Function]} | ||
style={ | ||
Object { | ||
"backgroundColor": "primaryColor", | ||
} | ||
} | ||
type="button"> | ||
<div | ||
className="auth0-lock-social-button-icon" | ||
style={ | ||
Object { | ||
"backgroundImage": "url(\'test\')", | ||
} | ||
} /> | ||
<div | ||
className="auth0-lock-social-button-text" | ||
style={ | ||
Object { | ||
"color": "foregroundColor", | ||
} | ||
}> | ||
label | ||
</div> | ||
</button> | ||
`; |
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,43 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
|
||
import { expectComponent, noop } from './testUtils' | ||
|
||
import AuthButton from 'ui/button/auth_button'; | ||
|
||
describe('AuthButton', () => { | ||
const defaultProps = { | ||
label: 'label', | ||
onClick: noop, | ||
strategy: 'strategy' | ||
}; | ||
it('renders correctly', () => { | ||
expectComponent( | ||
<AuthButton {...defaultProps} /> | ||
).toMatchSnapshot(); | ||
}); | ||
it('renders with style customizations', () => { | ||
expectComponent( | ||
<AuthButton | ||
{...defaultProps} | ||
icon="test" | ||
primaryColor="primaryColor" | ||
foregroundColor="foregroundColor" | ||
/> | ||
).toMatchSnapshot(); | ||
}); | ||
it('renders when `big` is false', () => { | ||
expectComponent( | ||
<AuthButton | ||
{...defaultProps} | ||
isBig={false} | ||
/> | ||
).toMatchSnapshot(); | ||
}); | ||
it('should trigger onClick when clicked', () => { | ||
const onClick = jest.fn(); | ||
const wrapper = mount(<AuthButton {...defaultProps} onClick={onClick} />); | ||
wrapper.find('button').simulate('click'); | ||
expect(onClick.mock.calls.length).toBe(1); | ||
}); | ||
}); |
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,9 @@ | ||
import React from 'react'; // eslint-disable-line | ||
import renderer from 'react-test-renderer'; | ||
|
||
export const expectComponent = (children) => { | ||
const component = renderer.create(children); | ||
return expect(component); | ||
}; | ||
|
||
export const noop = () => {}; |