コード例 #1
0
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 it('should callback with widget', (done) => {
   render(root, {}, (widget) => {
     expect(widget)
       .to.be.an.instanceof(HTMLElement)
     done()
   })
 })
コード例 #3
0
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 it('should render stylesheet', (done) => {
   render(root, {}, () => {
     expect(root.querySelector('style'))
       .to.be.an.instanceof(HTMLElement)
     done()
   })
 })
コード例 #5
0
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 ].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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 ].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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 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
ファイル: content.spec.js プロジェクト: ntkme/github-buttons
 it('should work', () => {
   render(root, {})
 })