Skip to content

test: use TestBed.createDirective() in directive specs, fix ShadowOnScroll and Collapse - #292

Merged
xidedix merged 4 commits into
v5.7from
test/create-directive
Oct 12, 2026
Merged

xidedix merged 4 commits into
v5.7from
test/create-directive

Conversation

@xidedix

@xidedix xidedix commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Directive specs use TestBed.createDirective() instead of a host test component; specs that need a parent, structural directives and the SVG IconDirective keep one.

Fixes found on the way:

  • ShadowOnScrollDirective: changing cShadowOnScroll left the old shadow class and an extra scroll subscription; 'none' did not disable it.
  • CollapseDirective: with animate=false, toggle() never reached [(visible)].

- 58 directive specs drop the host test component; inputs via inputBinding/twoWayBinding
- `new Directive()` instance checks replaced by host class/attribute assertions
- new specs: SidebarTogglerDirective, FormControlDirective range/color/host warning, ShadowOnScrollDirective scroll toggle, ToastCloseDirective click
- kept on a host component: specs that need a parent (dropdown, tabs, nav group, page item, navbar toggler), structural directives, markup-form tests (sidebar toggle), SVG host (IconDirective)
- ColDirective breakpoints as string values, like template attributes
- ButtonCloseDirective without a tabindex binding
- ModalToggleDirective with a bare cModalToggle (empty id)
- CollapseDirective visible as a two-way binding
- ThemeDirective light colorScheme without a dark binding
…shadow class and scroll listener

- before: the previous shadow class stayed on the host, every input change added a document scroll subscription, `'none'` subscribed and toggled `shadow-none`, and an already scrolled page got no shadow until the next scroll
- now: one effect with `onCleanup` owns the class and the subscription; it reads the scroll position on each run, `false`/`'none'` subscribe to nothing, and destroy removes the class
…imate is false

- before: with animate=false a visibility change after the first render applied the classes but emitted nothing, so [(visible)] never received toggle() results, and an animation interrupted by switching animate off left its inline size and transitionend listener behind
- now: the non-animated path ends through finishTransition, like the animated one: it emits `open`/`collapsed` and the new visible value for toggle() and input changes, and clears pending styles and listeners; the first render still emits nothing
@xidedix
xidedix merged commit f01a1ea into v5.7 Oct 12, 2026
9 checks passed
@xidedix
xidedix deleted the test/create-directive branch October 12, 2026 14:01
xidedix added a commit that referenced this pull request Oct 19, 2026
- fix(alert): hide and emit `visibleChange` when there is no opacity transition (#304)
- fix(carousel): measure each swipe from its own touchstart (#303)
- fix(collapse.directive): emit `visibleChange` and `collapseChange` when `animate` is false (#292)
- fix(dropdown): mirror the menu placement in a right-to-left context (#299)
- fix(dropdown, modal, offcanvas): Escape in an open dropdown leaves the container open (#298)
- fix(shadow-on-scroll.directive): changing `cShadowOnScroll` drops the old shadow class and scroll listener (#292)
- fix(sidebar): apply input changes after first render, scope state actions to their sidebar (#307)
- fix(sidebar-nav): apply multi-class item classes, style the label as a nav link (#309)
- fix(sidebar-nav-helper): `isActive()` handles array urls (#296)
- fix(sidebar-nav-icon.pipe): handle a missing item (#296)
- fix(table): keep one responsive wrapper and remove it on destroy (#305)
- fix(tabs): Home/End, one key manager, navigate and select by key (#306)
- fix: ignore key events without a key (#302)
- refactor(tab-pane): `OnPush`, signal state, host metadata (#294)
- refactor: drop `ngAcceptInputType_` from signal inputs (#293)
- test: run specs zoneless, drop `zone.js` (#295)
- test: use `TestBed.createDirective()` in directive specs (#292)
- test: cover untested paths across components and services (#300, #301, #308)
- ci: bump `actions/setup-node` (#297)
- chore(dependencies): update to Angular 22.2.3 (#310)

Verified: `npm ci`, lint, tests 30 + 1035 + 60, 3 prod builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant