( framework: string, harness: ComponentHarness, components: Components, )
| 892 | }; |
| 893 | |
| 894 | export const testComponents = ( |
| 895 | framework: string, |
| 896 | harness: ComponentHarness, |
| 897 | components: Components, |
| 898 | ): void => { |
| 899 | let store: Store; |
| 900 | |
| 901 | beforeEach(() => { |
| 902 | store = createStore() |
| 903 | .setTables({t1: {r1: {c1: 1}}, t2: {r1: {c1: 2}, r2: {c1: 3, c2: 4}}}) |
| 904 | .setValues({v1: 3, v2: 4}); |
| 905 | }); |
| 906 | |
| 907 | describe(`${framework} component scenarios`, () => { |
| 908 | describe('tables and values', () => { |
| 909 | test('TablesView basic, separator, debug, and update', async () => { |
| 910 | const {container, rerender, unmount} = harness.render( |
| 911 | components.TablesView, |
| 912 | {store}, |
| 913 | ); |
| 914 | expect(container.textContent).toEqual('1234'); |
| 915 | |
| 916 | await rerender({store, separator: harness.separator}); |
| 917 | expect(container.textContent).toEqual('1/234'); |
| 918 | |
| 919 | await rerender({store, separator: undefined, debugIds: true}); |
| 920 | expect(container.textContent).toEqual( |
| 921 | 't1:{r1:{c1:{1}}}t2:{r1:{c1:{2}}r2:{c1:{3}c2:{4}}}', |
| 922 | ); |
| 923 | |
| 924 | await harness.act(() => store.setCell('t1', 'r1', 'c1', 2)); |
| 925 | expect(container.textContent).toEqual( |
| 926 | 't1:{r1:{c1:{2}}}t2:{r1:{c1:{2}}r2:{c1:{3}c2:{4}}}', |
| 927 | ); |
| 928 | |
| 929 | unmount(); |
| 930 | }); |
| 931 | |
| 932 | test('TableView basic, separator, debug, and null id', async () => { |
| 933 | const {container, rerender, unmount} = harness.render( |
| 934 | components.TableView, |
| 935 | {store, tableId: 't2'}, |
| 936 | ); |
| 937 | expect(container.textContent).toEqual('234'); |
| 938 | |
| 939 | await rerender({store, tableId: 't2', separator: harness.separator}); |
| 940 | expect(container.textContent).toEqual('2/34'); |
| 941 | |
| 942 | await rerender({ |
| 943 | store, |
| 944 | tableId: 't2', |
| 945 | separator: undefined, |
| 946 | debugIds: true, |
| 947 | }); |
| 948 | expect(container.textContent).toEqual( |
| 949 | 't2:{r1:{c1:{2}}r2:{c1:{3}c2:{4}}}', |
| 950 | ); |
| 951 |
no test coverage detected
searching dependent graphs…