MCPcopy Create free account
hub / github.com/angular/angular / tests

Function tests

adev/src/content/examples/form-validation/e2e/src/app.e2e-spec.ts:69–149  ·  view source on GitHub ↗
(title: string)

Source from the content-addressed store, hash-verified

67}
68
69function tests(title: string) {
70 it('should display correct title', async () => {
71 expect(await page.title.getText()).toContain(title);
72 });
73
74 it('should not display submitted message before submit', async () => {
75 expect(await page.actorSubmitted.isElementPresent(by.css('p'))).toBe(false);
76 });
77
78 it('should have form buttons', async () => {
79 expect(await page.actorFormButtons.count()).toEqual(2);
80 });
81
82 it('should have error at start', async () => {
83 await expectFormIsInvalid();
84 });
85
86 // it('showForm', () => {
87 // page.form.getInnerHtml().then(html => console.log(html));
88 // });
89
90 it('should have disabled submit button', async () => {
91 expect(await page.actorFormButtons.get(0).isEnabled()).toBe(false);
92 });
93
94 it('resetting name to valid name should clear errors', async () => {
95 const ele = page.nameInput;
96 expect(await ele.isPresent()).toBe(true, 'nameInput should exist');
97 await ele.clear();
98 await ele.sendKeys(testName);
99 await expectFormIsValid();
100 });
101
102 it('should produce "required" error after clearing name', async () => {
103 await page.nameInput.clear();
104 // await page.roleInput.click(); // to blur ... didn't work
105 await page.nameInput.sendKeys('x', protractor.Key.BACK_SPACE); // ugh!
106 expect(await page.form.getAttribute('class')).toMatch('ng-invalid');
107 expect(await page.errorMessages.get(0).getText()).toContain('required');
108 });
109
110 it('should produce "at least 4 characters" error when name="x"', async () => {
111 await page.nameInput.clear();
112 await page.nameInput.sendKeys('x'); // too short
113 await expectFormIsInvalid();
114 expect(await page.errorMessages.get(0).getText()).toContain('at least 4 characters');
115 });
116
117 it('resetting name to valid name again should clear errors', async () => {
118 await page.nameInput.sendKeys(testName);
119 await expectFormIsValid();
120 });
121
122 it('should have enabled submit button', async () => {
123 const submitBtn = page.actorFormButtons.get(0);
124 expect(await submitBtn.isEnabled()).toBe(true);
125 });
126

Callers 1

app.e2e-spec.tsFile · 0.85

Calls 12

expectFormIsInvalidFunction · 0.85
expectFormIsValidFunction · 0.85
getTextMethod · 0.80
cssMethod · 0.80
elementMethod · 0.80
getMethod · 0.65
getAttributeMethod · 0.65
itFunction · 0.50
countMethod · 0.45
isEnabledMethod · 0.45
clearMethod · 0.45
clickMethod · 0.45

Tested by

no test coverage detected