Skip to content

Commit ba1403d

Browse files
committed
fix(core): set parent of parameter when using add
relates #120 Signed-off-by: Ingo Bürk <ingo.buerk@tngtech.com>
1 parent 134acd0 commit ba1403d

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

projects/ngqp/core/src/lib/model/query-param-group.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,19 @@ describe(QueryParamGroup.name, () => {
207207

208208
describe('add', () => {
209209
let group: QueryParamGroup;
210-
beforeEach(() => group = new QueryParamGroup({ q: stringParam }));
210+
beforeEach(() => group = new QueryParamGroup({}));
211211

212212
it('can add a new parameter to a group', () => {
213213
group.add('test', stringParam);
214214
expect(group.get('test')).toBe(stringParam);
215-
expect(group.value).toEqual({ q: null, test: null });
215+
expect(group.value).toEqual({ test: null });
216+
expect((stringParam as any).parent).not.toBe(null);
216217
});
217218

218219
it('throws if the name is already taken', () => {
219-
expect(() => group.add('q', stringParam))
220-
.toThrowError('A parameter with name q already exists.');
220+
group.add('test', stringParam);
221+
expect(() => group.add('test', stringParam))
222+
.toThrowError('A parameter with name test already exists.');
221223
});
222224
});
223225

projects/ngqp/core/src/lib/model/query-param-group.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export class QueryParamGroup {
9595
}
9696

9797
this.queryParams[ queryParamName ] = queryParam;
98+
queryParam._setParent(this);
9899
this._queryParamAdded$.next(queryParamName);
99100
}
100101

0 commit comments

Comments
 (0)