Passed
Push — master ( 52f960...2ac20a )
by Javier
02:29
created

T_IMPORT   A

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 1
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
dl 0
loc 1
rs 10
c 1
b 0
f 0
noi 0
wmc 5
mnd 0
bc 5
fnc 5
bpm 1
cpm 1
1
import VotingUrl from './voting_url'
2
const Url = require('url')
3
4
describe('a voting url', () => {
5
  const abaseUrl = 'http://domain.org'
6
  const anEventPoll = { 'id': '32' }
7
8
  const aVotingUrl = new VotingUrl(abaseUrl, anEventPoll)
9
10
  expect(aVotingUrl).toBeInstanceOf(VotingUrl)
11
12
  it('has base url and a voting poll', () => {
13
    expect(aVotingUrl.baseUrl).toBe(abaseUrl)
14
    expect(aVotingUrl.votingPoll).toBe(anEventPoll)
15
  })
16
17
  it('has a value equal to a valid voting url', () => {
18
    const actualUrl = Url.parse(aVotingUrl.value())
19
20
    expect(actualUrl.host).toBe(Url.parse(abaseUrl).host)
21
    expect(actualUrl.protocol).toBe(Url.parse(abaseUrl).protocol)
22
    expect(actualUrl.path).toBe('/voting/' + anEventPoll.id)
23
  })
24
25
  it('is not equal to a random url', () => {
26
    expect(aVotingUrl.equalsTo('http://www.wikipedia.org')).toBeFalsy()
27
  })
28
29
  it('is not equal to a random votingUrl', () => {
30
    const anotherVotingUrl = new VotingUrl('http://domain.org', { 'id': 33 })
31
    expect(aVotingUrl.equalsTo(anotherVotingUrl)).toBeFalsy()
32
  })
33
})
34