Ma77Ball opened a new issue, #5467:
URL: https://github.com/apache/texera/issues/5467
### Task Summary
`RegistrationRequestModalComponent`
(`frontend/src/app/common/service/user/registration-request-modal/registration-request-modal.component.ts`)
has no `*.spec.ts` file. It is a small form modal with no service
dependencies. It seeds
`name` and `email` from the injected `NZ_MODAL_DATA`, and `getValues()`
returns the
trimmed `affiliation` and `reason`. Both are easy to test directly.
### What to do (step by step)
1. Create the spec file next to the component, with the Apache license
header.
2. Provide `NZ_MODAL_DATA` with `{ uid, email, name }`.
3. Assert constructor seeding and `getValues()` trimming behavior.
4. Run `yarn test -- registration-request-modal`, then `yarn lint`.
### Cover
- `should create`.
- Constructor copies `data.name` into `name` and `data.email` into `email`.
- Constructor handles a null/empty `data` gracefully (`name`/`email` become
`""`).
(You can test this by providing `NZ_MODAL_DATA` as `null`.)
- `getValues()` trims whitespace: set `component.affiliation = " UCI "` and
`component.reason = " hi "`, expect `{ affiliation: "UCI", reason: "hi"
}`.
### Starter skeleton
```ts
// <Apache license header>
import { TestBed } from "@angular/core/testing";
import { NZ_MODAL_DATA } from "ng-zorro-antd/modal";
import { RegistrationRequestModalComponent } from
"./registration-request-modal.component";
function setup(data: any) {
TestBed.configureTestingModule({
imports: [RegistrationRequestModalComponent],
providers: [{ provide: NZ_MODAL_DATA, useValue: data }],
});
const fixture = TestBed.createComponent(RegistrationRequestModalComponent);
return fixture.componentInstance;
}
describe("RegistrationRequestModalComponent", () => {
it("seeds name and email from modal data", () => {
const c = setup({ uid: 1, email: "[email protected]", name: "Ada" });
expect(c.name).toBe("Ada");
expect(c.email).toBe("[email protected]");
});
it("trims affiliation and reason in getValues()", () => {
const c = setup({ uid: 1, email: "", name: "" });
c.affiliation = " UCI ";
c.reason = " hi ";
expect(c.getValues()).toEqual({ affiliation: "UCI", reason: "hi" });
});
});
```
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]