Total Complexity | 5 |
Complexity/F | 1 |
Lines of Code | 33 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 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 |