This repository has been archived by the owner on Jan 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make OData sorting predictable and unique
Change-type: patch
- Loading branch information
Andrea Rosci
authored and
Andrea Rosci
committed
Mar 5, 2024
1 parent
2e768cb
commit 6841a01
Showing
3 changed files
with
51 additions
and
53 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
import React from "react"; | ||
import { mount } from "enzyme"; | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { | ||
autoUIRunTransformers, | ||
autoUIGetModelForCollection, | ||
AutoUIProps, | ||
AutoUI, | ||
} from "./index"; | ||
autoUIRunTransformers, | ||
autoUIGetModelForCollection, | ||
AutoUIProps, | ||
AutoUI, | ||
} from './index'; | ||
import { | ||
dataExample, | ||
AugmentedSshKey, | ||
transformers, | ||
model as sshKeyModel, | ||
} from "./models/example"; | ||
import { Provider, Table } from "rendition"; | ||
dataExample, | ||
AugmentedSshKey, | ||
transformers, | ||
model as sshKeyModel, | ||
} from './models/example'; | ||
import { Provider, Table } from 'rendition'; | ||
const props = {} as AutoUIProps<AugmentedSshKey>; | ||
const TestAutoUI = () => <Demo {...props} />; | ||
|
||
const Demo = ({ data, model, ...otherProps }: AutoUIProps<AugmentedSshKey>) => { | ||
const memoizedData = React.useMemo( | ||
() => | ||
autoUIRunTransformers(dataExample, transformers, { | ||
accessRole: "administrator", | ||
}), | ||
[dataExample] | ||
) as AugmentedSshKey[]; | ||
const memoizedData = React.useMemo( | ||
() => | ||
autoUIRunTransformers(dataExample, transformers, { | ||
accessRole: 'administrator', | ||
}), | ||
[dataExample], | ||
) as AugmentedSshKey[]; | ||
|
||
return ( | ||
<AutoUI<AugmentedSshKey> | ||
data={data ?? memoizedData} | ||
model={model ?? autoUIGetModelForCollection(sshKeyModel)} | ||
actions={[]} | ||
{...otherProps} | ||
/> | ||
); | ||
return ( | ||
<AutoUI<AugmentedSshKey> | ||
data={data ?? memoizedData} | ||
model={model ?? autoUIGetModelForCollection(sshKeyModel)} | ||
actions={[]} | ||
{...otherProps} | ||
/> | ||
); | ||
}; | ||
|
||
describe("AutoUI", () => { | ||
describe("Collection component", () => { | ||
it("should render the collection with N results", () => { | ||
const component = mount( | ||
<Provider> | ||
<TestAutoUI /> | ||
</Provider> | ||
); | ||
const table = component.find(Table); | ||
const tableRows = table.find( | ||
'[data-display="table-body"] [data-display="table-row"]' | ||
); | ||
describe('AutoUI', () => { | ||
describe('Collection component', () => { | ||
it('should render the collection with N results', () => { | ||
const component = mount( | ||
<Provider> | ||
<TestAutoUI /> | ||
</Provider>, | ||
); | ||
const table = component.find(Table); | ||
const tableRows = table.find( | ||
'[data-display="table-body"] [data-display="table-row"]', | ||
); | ||
|
||
expect(tableRows).toHaveLength(dataExample.length); | ||
}); | ||
}); | ||
expect(tableRows).toHaveLength(dataExample.length); | ||
}); | ||
}); | ||
}); |
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