-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix issue rendering delete properties action (#2460)
* fix issues rendering delete properties actions * no longer recurse on schema Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
- Loading branch information
1 parent
be2d064
commit e14850e
Showing
3 changed files
with
54 additions
and
10 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Composer/packages/extensions/adaptive-form/src/utils/__tests__/resolvePropSchema.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { resolvePropSchema } from '../resolvePropSchema'; | ||
import { resolveRef } from '../resolveRef'; | ||
|
||
jest.mock('../resolveRef', () => ({ | ||
resolveRef: jest.fn().mockImplementation(obj => ({ | ||
...obj, | ||
resolved: true, | ||
})), | ||
})); | ||
|
||
describe('resolvePropSchema', () => { | ||
const definitions = { | ||
foo: { | ||
title: 'Foo Title', | ||
}, | ||
}; | ||
|
||
it('returns undefined if the schema does not have properties', () => { | ||
expect(resolvePropSchema({}, 'foo', definitions)).toBe(undefined); | ||
}); | ||
|
||
it('resolves the property schema', () => { | ||
const schema = { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
type: 'object', | ||
properties: { | ||
bar: { | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
// @ts-ignore | ||
const resolved = resolvePropSchema(schema, 'foo', definitions); | ||
expect(resolveRef).toBeCalledWith(schema.properties.foo, definitions); | ||
|
||
expect(resolved).toMatchObject({ | ||
...schema.properties.foo, | ||
resolved: true, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters