示例#1
0
 it('should append the button to widget when the necessary config is given', (done) => {
   render(root, {}, () => {
     expect(root.querySelector('.btn'))
       .to.be.an.instanceof(HTMLElement)
     done()
   })
 })
示例#2
0
 it('should callback with widget', (done) => {
   render(root, {}, (widget) => {
     expect(widget)
       .to.be.an.instanceof(HTMLElement)
     done()
   })
 })
示例#3
0
 it('should append the button with the default icon', (done) => {
   render(root, {}, () => {
     expect(root.querySelector('.btn').querySelector('.octicon.octicon-mark-github'))
       .to.be.an.instanceof(SVGElement)
     done()
   })
 })
示例#4
0
 it('should render stylesheet', (done) => {
   render(root, {}, () => {
     expect(root.querySelector('style'))
       .to.be.an.instanceof(HTMLElement)
     done()
   })
 })
示例#5
0
 it('should add lg to widget.className when data-size is large', (done) => {
   render(root, {
     'data-size': 'large'
   }, () => {
     expect(root.querySelector('.widget.lg'))
       .to.be.an.instanceof(HTMLElement)
     done()
   })
 })
示例#6
0
 it('should create a widget with className widget', (done) => {
   render(root, {}, () => {
     expect(root.querySelector('.widget'))
       .to.be.an.instanceof(HTMLElement)
     expect(root.querySelector('.widget.lg'))
       .to.be.null
     done()
   })
 })
示例#7
0
 it('should append the button with the default if given icon is invalid', (done) => {
   render(root, {
     'data-icon': 'null'
   }, () => {
     expect(root.querySelector('.btn').querySelector('.octicon.octicon-mark-github'))
       .to.be.an.instanceof(SVGElement)
     done()
   })
 })
示例#8
0
 it('should append the button with given icon', (done) => {
   render(root, {
     'data-icon': 'octicon-star'
   }, () => {
     expect(root.querySelector('.btn').querySelector('.octicon.octicon-star'))
       .to.be.an.instanceof(SVGElement)
     done()
   })
 })
示例#9
0
 it('should append the button with given href', (done) => {
   const config = {
     'href': 'https://ntkme.github.com/'
   }
   render(root, config, () => {
     expect(root.querySelector('.btn').getAttribute('href'))
       .to.equal(config.href)
     done()
   })
 })
示例#10
0
 it('should append the button with given aria label', (done) => {
   const config = {
     'aria-label': 'GitHub'
   }
   render(root, config, () => {
     expect(root.querySelector('.btn').getAttribute('aria-label'))
       .to.equal(config['aria-label'])
     done()
   })
 })
示例#11
0
 it('should append the button with given text', (done) => {
   const config = {
     'data-text': 'Follow'
   }
   render(root, config, () => {
     expect(root.querySelector('.btn').lastChild.innerHTML)
       .to.equal(config['data-text'])
     done()
   })
 })
示例#12
0
 ].map(href => new Promise(resolve => {
   render(root, {
     href
   }, (widget) => {
     expect(widget.querySelector('.btn').href)
       .to.equal(href)
     expect(widget.querySelector('.btn').target)
       .to.equal('_top')
     resolve()
   })
 })))
示例#13
0
 it('should append the count when a known button type is given', (done) => {
   const config = {
     'href': 'https://github.com/ntkme',
     'data-show-count': 'true'
   }
   render(root, config, (widget) => {
     expect(widget.querySelector('.social-count'))
       .to.be.an.instanceof(HTMLElement)
     done()
   })
 })
示例#14
0
 it('should not append the count for unknown button type', (done) => {
   const config = {
     'href': 'https://github.com/',
     'data-show-count': 'true'
   }
   render(root, config, (widget) => {
     expect(widget.querySelector('.social-count'))
       .to.be.null
     done()
   })
 })
示例#15
0
 it('should create a button with href # if domain is not github', (done) => {
   render(root, {
     'href': 'https://twitter/ntkme'
   }, () => {
     expect(root.querySelector('.btn').href)
       .to.equal(document.location.href + '#')
     expect(root.querySelector('.btn').target)
       .to.equal('_self')
     done()
   })
 })
示例#16
0
 ].map(href => new Promise(resolve => {
   render(root, {
     href
   }, (widget) => {
     expect(widget.querySelector('.btn').href)
       .to.equal(document.location.href + '#')
     expect(widget.querySelector('.btn').target)
       .to.equal('_self')
     resolve()
   })
 })))
示例#17
0
 it('should append the count for button whose link has a tailing slash, a query, and a hash', (done) => {
   const config = {
     'href': 'https://github.com/ntkme/?tab=repositories#github-buttons',
     'data-show-count': 'true'
   }
   render(root, config, (widget) => {
     const count = widget.querySelector('.social-count')
     expect(count.href)
       .to.equal('https://github.com/ntkme/followers')
     done()
   })
 })
示例#18
0
 it('should append button without count when count has error', (done) => {
   const config = {
     'href': 'https://github.com/404',
     'data-show-count': 'true'
   }
   render(root, config, (widget) => {
     const btn = widget.querySelector('.btn')
     expect(btn.href)
       .to.equal(config.href)
     expect(widget.querySelector('.social-count'))
       .to.be.null
     done()
   })
 })
示例#19
0
 it('should append the count for fork button', (done) => {
   const config = {
     'href': 'https://github.com/ntkme/github-buttons/fork',
     'data-show-count': 'true'
   }
   render(root, config, (widget) => {
     const count = widget.querySelector('.social-count')
     expect(count.href)
       .to.equal('https://github.com/ntkme/github-buttons/network')
     expect(count.lastChild.innerHTML)
       .to.equal('94')
     expect(count.getAttribute('aria-label'))
       .to.equal('94 forks on GitHub')
     done()
   })
 })
示例#20
0
 it('should append the count for issue button when it links to new issue', (done) => {
   const config = {
     'href': 'https://github.com/ntkme/github-buttons/issues/new',
     'data-show-count': 'true'
   }
   render(root, config, (widget) => {
     const count = widget.querySelector('.social-count')
     expect(count.href)
       .to.equal('https://github.com/ntkme/github-buttons/issues')
     expect(count.lastChild.innerHTML)
       .to.equal('1')
     expect(count.getAttribute('aria-label'))
       .to.equal('1 open issue on GitHub')
     done()
   })
 })
示例#21
0
 it('should work', () => {
   render(root, {})
 })