-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
EnforceActionExportRestrictions.ts
69 lines (59 loc) · 3.02 KB
/
EnforceActionExportRestrictions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import * as IOU from '@libs/actions/IOU';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as Policy from '@userActions/Policy/Policy';
import * as Task from '@userActions/Task';
// There are some methods that are OK to use inside an action file, but should not be exported. These are typically methods that look up and return Onyx data.
// The correct pattern to use is that every file will use it's own withOnyx or Onyx.connect() to access the Onyx data it needs. This prevents data from becoming stale
// and prevents side-effects that you may not be aware of. It also allows each file to access Onyx data in the most performant way. More context can be found in
// https://github.com/Expensify/App/issues/27262
describe('ReportUtils', () => {
it('does not export getParentReport', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(ReportUtils.getParentReport).toBeUndefined();
});
it('does not export isOneTransactionReport', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(ReportUtils.isOneTransactionReport).toBeUndefined();
});
it('does not export getPolicy', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(ReportUtils.getPolicy).toBeUndefined();
});
it('does not export getAllReportActions', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(ReportUtils.getAllReportActions).toBeUndefined();
});
});
describe('Policy', () => {
it('does not export getPolicy', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(Policy.getPolicy).toBeUndefined();
});
});
describe('IOU', () => {
it('does not export getPolicy', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(IOU.getPolicy).toBeUndefined();
});
it('does not export getReport', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(IOU.getReportOrDraftReport).toBeUndefined();
});
});
describe('Task', () => {
it('does not export getParentReport', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(Task.getParentReport).toBeUndefined();
});
it('does not export getParentReportAction', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(Task.getParentReportAction).toBeUndefined();
});
});
describe('OptionsListUtils', () => {
it('does not export getReport', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(OptionsListUtils.getReportOrDraftReport).toBeUndefined();
});
});