Skip to content

Commit

Permalink
added e2e tests for contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
daha committed Jul 18, 2012
1 parent 914ab41 commit 3a9022a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
13 changes: 12 additions & 1 deletion test/e2e/github-responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ githubResponses.repos_foo_repoA = {data: {
'forks': 1
}};

githubResponses.repos_foo_repoA_contributors = {data: []};
githubResponses.repos_foo_repoA_contributors = {data: [
{
'login': 'foo',
'contributions': 10,
'avatar_url': '../test/e2e/foo.png'
},
{
'login': 'bar',
'contributions': 1,
'avatar_url': ''
}
]};

githubResponses.repos_foo_repoB = {data: {
'owner': {
Expand Down
49 changes: 48 additions & 1 deletion test/e2e/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ describe('GitHub Contributors with mocked data', function () {
it('should transition back to the user page (foo)', function () {
element('.back a').click();
expect(browser().location().url()).toBe('/github/foo/');

});

it('should display repo info', function () {
Expand All @@ -185,6 +184,54 @@ describe('GitHub Contributors with mocked data', function () {
.toMatch(/0\s*Watchers\b/);
expect(element('.repo-forks').text()).toMatch(/1\s*Fork\b/);
});

it('should display number of Contributors', function () {
expect(element('h2').text()).toBe('Project Contributors (2)');
expect(repeater('.contributor').count()).toBe(2);
});

it('should display contributors (first contributor)', function () {
expect(repeater('.contributor .contributor-name').row(0))
.toEqual(['foo']);
expect(repeater('.contributor .contributor-contributions')
.row(0)).toEqual(['10']);

expect(element('li:nth-child(1) a').attr('title'))
.toBe('foo has 10 Contributions');

expect(element('li:nth-child(1) img').attr('alt'))
.toBe('foo\'s avatar');

expect(element('li:nth-child(1) img').attr('src'))
.toBe('../test/e2e/foo.png');
});

it('should display contributors (second contributor)', function () {
expect(repeater('.contributor .contributor-name').row(1))
.toEqual(['bar']);
expect(repeater('.contributor .contributor-contributions')
.row(1)).toEqual(['1']);

// TODO: It should be '1 Contribution'
expect(element('li:nth-child(2) a').attr('title'))
.toBe('bar has 1 Contributions');

expect(element('li:nth-child(2) img').attr('alt'))
.toBe('bar\'s avatar');

expect(element('li:nth-child(2) img').attr('src'))
.toBe('');
});

it('should transition to contributor on click (foo)', function () {
element('li:nth-child(1) a').click();
expect(browser().location().url()).toBe('/github/foo/');
});

it('should transition to contributor on click (bar)', function () {
element('li:nth-child(2) a').click();
expect(browser().location().url()).toBe('/github/bar/');
});
});

describe('repo page (foo/repoB)', function () {
Expand Down

0 comments on commit 3a9022a

Please sign in to comment.