-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed lint, added test cases, added autoheight
- Loading branch information
1 parent
ac49fe5
commit f6266a9
Showing
4 changed files
with
198 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,28 +1,193 @@ | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import Button from '../index'; | ||
import { mount } from 'enzyme'; | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
import { TwitterFollowButton, TwitterHashtagButton, TwitterMentionButton, TwitterTweetEmbed, TwitterTimelineEmbed } from './../index'; | ||
|
||
const { describe, it } = global; | ||
|
||
describe('Button', () => { | ||
it('should show the given text', () => { | ||
const text = 'The Text'; | ||
const wrapper = shallow(<Button>{text}</Button>); | ||
expect(wrapper.text()).to.be.equal(text); | ||
}); | ||
|
||
it('should handle the click event', () => { | ||
const clickMe = sinon.stub(); | ||
// Here we do a JSDOM render. So, that's why we need to | ||
// wrap this with a div. | ||
const wrapper = mount( | ||
<div> | ||
<Button onClick={ clickMe }>ClickMe</Button> | ||
</div> | ||
); | ||
|
||
wrapper.find('button').simulate('click'); | ||
expect(clickMe.callCount).to.be.equal(1); | ||
describe('Twitter follow button', () => { | ||
it('Should create follow button without options', () => { | ||
expect(function () { | ||
mount(<TwitterFollowButton screenName="saurabhnemade" />); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create follow button with options', () => { | ||
expect(function () { | ||
mount(<TwitterFollowButton screenName="saurabhnemade" options={{ size: 'large' }} />); | ||
}).to.not.throw(); | ||
}); | ||
}); | ||
|
||
describe('Twitter hashtag button', () => { | ||
it('Should create hashtag button without options', () => { | ||
expect(function () { | ||
mount(<TwitterHashtagButton tag="saurabhnemade" />); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create hashtag button with options', () => { | ||
expect(function () { | ||
mount(<TwitterHashtagButton tag="saurabhnemade" options={{ size: 'large' }} />); | ||
}).to.not.throw(); | ||
}); | ||
}); | ||
|
||
describe('Twitter Mention button', () => { | ||
it('Should create Mention button without options', () => { | ||
expect(function () { | ||
mount(<TwitterMentionButton screenName="saurabhnemade" />); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create Mention button with options', () => { | ||
expect(function () { | ||
mount(<TwitterMentionButton screenName="saurabhnemade" options={{ size: 'large' }} />); | ||
}).to.not.throw(); | ||
}); | ||
}); | ||
|
||
describe('Twitter tweet view', () => { | ||
it('Should create tweet view', () => { | ||
expect(function () { | ||
mount(<TwitterTweetEmbed tweetId="933354946111705097" />); | ||
}).to.not.throw(); | ||
}); | ||
}); | ||
|
||
describe('Twitter timeline view', () => { | ||
it('Should create timeline with screen name without options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="profile" | ||
screenName="saurabhnemade" | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline with screen name with options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="profile" | ||
screenName="saurabhnemade" | ||
options={{ height: 400 }} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline with userid without options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="profile" | ||
userId={1934309676} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline with userid without options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="profile" | ||
userId={1934309676} | ||
options={{ height: 400 }} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline likes with screenname without options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="likes" | ||
screenName="saurabhnemade" | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline likes with screenname with options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="likes" | ||
screenName="saurabhnemade" | ||
options={{ height: 400 }} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline likes with userid without options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="likes" | ||
userId={1934309676} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline likes with userid with options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="likes" | ||
userId={1934309676} | ||
options={{ height: 400 }} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline list with ownerScreenName and slug without options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="list" | ||
ownerScreenName="palafo" | ||
slug="breakingnews" | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline list with ownerScreenName and slug with options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="list" | ||
ownerScreenName="palafo" | ||
slug="breakingnews" | ||
options={{ height: 400 }} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline list with list id without options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="list" | ||
id={8044403} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline list with list id with options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="list" | ||
id={8044403} | ||
options={{ height: 400 }} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline list with list id without options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="collection" | ||
id={'588824628950269952'} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Should create timeline list with list id with options', () => { | ||
expect(function () { | ||
mount(<TwitterTimelineEmbed | ||
sourceType="collection" | ||
id={'588824628950269952'} | ||
options={{ height: 400 }} | ||
/>); | ||
}).to.not.throw(); | ||
}); | ||
}); |