|
| 1 | +describe('Github Search page', () => { |
| 2 | + // before each 'it' of the following describe: |
| 3 | + beforeEach(() => { |
| 4 | + // go to page (if not yet) |
| 5 | + goToUrl('/#/github'); |
| 6 | + }); |
| 7 | + it('should have a correct title', () => { |
| 8 | + expect(browser.getTitle()).toEqual('Topheman - react-es6-redux'); |
| 9 | + }); |
| 10 | + describe('Scenario - "original"', () => { |
| 11 | + it('should have the correct message when form untouched', () => { |
| 12 | + const text = element.all(by.css('form ~ p')).first().getText(); |
| 13 | + expect(text).toEqual('Just search for a Github user or organization ... or access directly to my profile.'); |
| 14 | + }); |
| 15 | + }); |
| 16 | + describe('Scenario - "No results"', () => { |
| 17 | + it('should output "No results" when searching for "other"', () => { |
| 18 | + const username = browser.findElement(by.id('user-name')); |
| 19 | + username.sendKeys('other', protractor.Key.ENTER).then(() => { |
| 20 | + const text = element.all(by.css('form ~ div')).first().getText(); |
| 21 | + expect(text).toEqual('No results.'); |
| 22 | + }); |
| 23 | + }); |
| 24 | + }); |
| 25 | + describe('Scenario - "One result"', () => { |
| 26 | + beforeEach((done) => { |
| 27 | + const username = browser.findElement(by.id('user-name')); |
| 28 | + username.sendKeys('topheman', protractor.Key.ENTER).then(done); |
| 29 | + }); |
| 30 | + it('should output only one result when searching for "topheman" - with correct header', () => { |
| 31 | + const resultHeader = element.all(by.css('form ~ div div.panel-heading')).first().getText(); |
| 32 | + expect(resultHeader).toEqual('Total result : 1 / showing : 1'); |
| 33 | + }); |
| 34 | + it('should output only one result when searching for "topheman" - with correct body', () => { |
| 35 | + element.all(by.css('form ~ div div.list-group a')).getText().then((resultLine) => { |
| 36 | + expect(resultLine[0]).toEqual('topheman'); |
| 37 | + }); |
| 38 | + }); |
| 39 | + }); |
| 40 | + describe('Scenario - "Multiple results"', () => { |
| 41 | + beforeEach((done) => { |
| 42 | + const username = browser.findElement(by.id('user-name')); |
| 43 | + username.sendKeys('tophe', protractor.Key.ENTER).then(done); |
| 44 | + }); |
| 45 | + it('should output multiple results when searching for "tophe" - with correct header', () => { |
| 46 | + const resultHeader = element.all(by.css('form ~ div div.panel-heading')).first().getText(); |
| 47 | + expect(resultHeader).toEqual('Total results : 270 / showing : 30'); |
| 48 | + }); |
| 49 | + it('should output multiple results when searching for "tophe" - with correct body', () => { |
| 50 | + element.all(by.css('form ~ div div.list-group a')).getText().then((resultLine) => { |
| 51 | + expect(resultLine[0]).toEqual('tophe'); |
| 52 | + expect(resultLine[3]).toEqual('topheman'); |
| 53 | + }); |
| 54 | + }); |
| 55 | + }); |
| 56 | + describe('Click on a result', () => { |
| 57 | + beforeEach((done) => { |
| 58 | + const username = browser.findElement(by.id('user-name')); |
| 59 | + username.sendKeys('topheman', protractor.Key.ENTER).then(done); |
| 60 | + }); |
| 61 | + it('should redirect to profile page when clicking on list item', () => { |
| 62 | + browser.findElement(by.css('form ~ div div.list-group a')).click().then(() => { |
| 63 | + expect(browser.getCurrentUrl()).toMatch(/\/#\/github\/user\/topheman/); |
| 64 | + }); |
| 65 | + }); |
| 66 | + }); |
| 67 | +}); |
0 commit comments