Skip to content

Commit

Permalink
Created a few new test cases for uiView for new features in component…
Browse files Browse the repository at this point in the history
…s inputs.
  • Loading branch information
lindolo25 committed Dec 23, 2024
1 parent fd9b7ee commit 5ef4430
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion test/uiView/resolveBinding.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Inject, Input } from '@angular/core';
import { Component, Inject, input, Input } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Ng2StateDeclaration, UIRouterModule, UIView } from '../../src';
import { By } from '@angular/platform-browser';
Expand All @@ -18,6 +18,14 @@ describe('uiView', () => {
@Input('resolve3') _resolve3;
@Input('resolve4') _resolve4;
@Input() resolve5;
@Input({ alias: 'resolve6' }) _resolve6;
@Input({ alias: 'resolve7' }) _resolve7;
@Input({ transform: (value: string) => `${value}1` }) resolve8;
resolve9 = input<string>("");
resolve10 = input<string>("");
_resolve11 = input<string>("", { alias: 'resolve11' });
_resolve12 = input<string>("", { alias: 'resolve12' });
resolve13 = input<string, string>("", { transform: value => `${value}1` });
}

let comp: ManyResolvesComponent;
Expand All @@ -32,13 +40,24 @@ describe('uiView', () => {
// component_input: 'resolve name'
resolve2: 'Resolve2',
resolve4: 'Resolve4',
resolve7: 'Resolve7',
resolve10: 'Resolve10',
resolve12: 'Resolve12'
},
resolve: [
{ token: 'resolve1', resolveFn: () => 'resolve1' },
{ token: 'Resolve2', resolveFn: () => 'resolve2' },
{ token: 'resolve3', resolveFn: () => 'resolve3' },
{ token: 'Resolve4', resolveFn: () => 'resolve4' },
new Resolvable('resolve5', () => 'resolve5', [], { async: 'NOWAIT' }),
{ token: 'resolve6', resolveFn: () => 'resolve6' },
{ token: 'Resolve7', resolveFn: () => 'resolve7' },
{ token: 'resolve8', resolveFn: () => 'resolve8' },
{ token: 'resolve9', resolveFn: () => 'resolve9' },
{ token: 'Resolve10', resolveFn: () => 'resolve10' },
{ token: 'resolve11', resolveFn: () => 'resolve11' },
{ token: 'Resolve12', resolveFn: () => 'resolve12' },
{ token: 'resolve13', resolveFn: () => 'resolve13' }
],
};

Expand Down Expand Up @@ -80,6 +99,38 @@ describe('uiView', () => {
expect(typeof comp.resolve5.then).toBe('function');
});

it('should bind resolve by alias to component input templateName', () => {
expect(comp._resolve6).toBe('resolve6');
});

it('should bind resolve by alias to the component input templateName specified in state `bindings`', () => {
expect(comp._resolve7).toBe('resolve7');
});

it('should bind resolve to the component input name and transform its value', () => {
expect(comp.resolve8).toBe('resolve81');
});

it('should bind resolve by name to component input signal name', () => {
expect(comp.resolve9()).toBe('resolve9');
});

it('should bind resolve by name to the component input signal specified by `bindings`', () => {
expect(comp.resolve10()).toBe('resolve10');
});

it('should bind resolve by name to component input signal templateName', () => {
expect(comp._resolve11()).toBe('resolve11');
});

it('should bind resolve by name to the component input signal templateName specified in state `bindings`', () => {
expect(comp._resolve12()).toBe('resolve12');
});

it('should bind resolve to the component input signal name and transform its value', () => {
expect(comp.resolve13()).toBe('resolve131');
});

/////////////////////////////////////////

it('should inject resolve by name to constructor', () => {
Expand Down

0 comments on commit 5ef4430

Please sign in to comment.