-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #7
- Loading branch information
Showing
5 changed files
with
150 additions
and
77 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { browser } from 'protractor'; | ||
import { CheckboxPage } from './checkbox.po'; | ||
|
||
describe('Checkbox', () => { | ||
let page: CheckboxPage; | ||
|
||
beforeEach(async() => { | ||
page = new CheckboxPage(); | ||
await page.go(); | ||
}); | ||
|
||
it('dovrebbe iniziare spuntato e abilitato', async () => { | ||
expect(await page.getRisultatoCheckboxChecked()).toBeTruthy(); | ||
expect(await page.getRisultatoCheckboxDisabled()).toBeFalsy(); | ||
}); | ||
|
||
it('dovrebbe interagire con l\'utente', async () => { | ||
await page.clickRisultatoCheckbox(); | ||
let actual = await page.getRisultatoCheckboxChecked(); | ||
expect(actual).toBeFalsy(); | ||
await page.clickRisultatoCheckbox(); | ||
actual = await page.getRisultatoCheckboxChecked(); | ||
expect(actual).toBeTruthy(); | ||
}); | ||
|
||
it('dovrebbe permettere di modificare la spunta', async () => { | ||
await page.clickSpuntatoCheckbox(); | ||
expect(await page.getRisultatoCheckboxChecked()).toBeFalsy(); | ||
await page.clickSpuntatoCheckbox(); | ||
expect(await page.getRisultatoCheckboxChecked()).toBeTruthy(); | ||
}); | ||
|
||
it('dovrebbe permettere di modificare l\'abilitazione', async () => { | ||
await page.clickDisabilitatoCheckbox(); | ||
expect(await page.getRisultatoCheckboxDisabled()).toBeTruthy(); | ||
await page.clickDisabilitatoCheckbox(); | ||
expect(await page.getRisultatoCheckboxDisabled()).toBeFalsy(); | ||
}); | ||
|
||
it('dovrebbe evitare di far modificare la spunta se disabilitato', async () => { | ||
await page.clickDisabilitatoCheckbox(); | ||
await page.clickRisultatoCheckbox(); | ||
expect(await page.getRisultatoCheckboxChecked()).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { browser, by, element } from 'protractor'; | ||
|
||
export class CheckboxPage { | ||
private readonly ID_CHECBOX_SPUNTATO = 'checkbox-0'; | ||
private readonly ID_CHECBOX_DISABILITATO = 'checkbox-1'; | ||
private readonly ID_CHECBOX_RISULTATO = 'checkbox-2'; | ||
|
||
private readonly ATTR_FOR_LABEL_SPUNTATO = this.getLabelForAttribute(this.ID_CHECBOX_SPUNTATO); | ||
private readonly ATTR_FOR_LABEL_DISABILITATO = this.getLabelForAttribute(this.ID_CHECBOX_DISABILITATO); | ||
private readonly ATTR_FOR_LABEL_RISULTATO = this.getLabelForAttribute(this.ID_CHECBOX_RISULTATO); | ||
|
||
private readonly ATTR_CHECKED = 'checked'; | ||
private readonly ATTR_DISABLED = 'disabled'; | ||
|
||
async go() { | ||
return await browser.get('/checkbox'); | ||
} | ||
|
||
async clickSpuntatoCheckbox() { | ||
await element(by.css(this.ATTR_FOR_LABEL_SPUNTATO)).click(); | ||
} | ||
|
||
async clickDisabilitatoCheckbox() { | ||
await element(by.css(this.ATTR_FOR_LABEL_DISABILITATO)).click(); | ||
} | ||
|
||
async clickRisultatoCheckbox() { | ||
await element(by.css(this.ATTR_FOR_LABEL_RISULTATO)).click(); | ||
} | ||
|
||
async getRisultatoCheckboxChecked() { | ||
return this.getRisultatoCheckbox().getAttribute(this.ATTR_CHECKED); | ||
} | ||
|
||
async getRisultatoCheckboxDisabled() { | ||
return this.getRisultatoCheckbox().getAttribute(this.ATTR_DISABLED); | ||
} | ||
|
||
private getRisultatoCheckbox() { | ||
return element(by.id(this.ID_CHECBOX_RISULTATO)); | ||
} | ||
|
||
private getLabelForAttribute(attr: string) { | ||
return `[for="${attr}"]`; | ||
} | ||
} |
Oops, something went wrong.