• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cartesi / rollups-explorer / 10497914455

21 Aug 2024 09:40PM UTC coverage: 93.39% (-0.4%) from 93.766%
10497914455

Pull #232

github

nevendyulgerov
test(apps/web): Add unit tests
Pull Request #232: #229 Add import and export for specifications

1210 of 1432 branches covered (84.5%)

Branch coverage included in aggregate %.

486 of 569 new or added lines in 8 files covered. (85.41%)

50 existing lines in 10 files now uncovered.

12863 of 13637 relevant lines covered (94.32%)

45.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.36
/apps/web/src/components/specification/transfer/validator.ts
1
import { validateSpecificationImport as v1Validator } from "./validators/v1";
1✔
2
import { SpecificationTransfer } from "../types";
1✔
3
import { isFunction } from "ramda-adjunct";
1✔
4

1✔
5
interface Validators {
1✔
6
    [key: string]: (specification: SpecificationTransfer) => Promise<void>;
1✔
7
}
1✔
8

1✔
9
const validators: Validators = {
1✔
10
    "1": v1Validator,
1✔
11
} as const;
1✔
12

1✔
13
export const VALIDATOR_VERSIONS = Object.keys(validators);
1✔
14

1✔
15
export const VALIDATOR_VERSION =
1✔
16
    VALIDATOR_VERSIONS[VALIDATOR_VERSIONS.length - 1];
1✔
17

1✔
18
export const validateSpecification = (specification: SpecificationTransfer) => {
1✔
19
    const specificationVersion = specification.version?.toString();
21✔
20

21✔
21
    return new Promise((resolve, reject) => {
21✔
22
        if (!VALIDATOR_VERSIONS.includes(specificationVersion)) {
21✔
23
            return reject([
1✔
24
                `Invalid 'version' field. Version must be of numeric value and must match one of the following values: ${VALIDATOR_VERSIONS.join(
1✔
25
                    ", ",
1✔
26
                )}.`,
1✔
27
            ]);
1✔
28
        }
1✔
29

20✔
30
        const validator =
20✔
31
            validators[specificationVersion as keyof typeof validators];
20✔
32

20✔
33
        if (!isFunction(validator)) {
21!
NEW
34
            return reject([
×
NEW
35
                "Missing validator for this specification version. Please contact support for further assistance.",
×
NEW
36
            ]);
×
NEW
37
        }
✔
38

20✔
39
        validator(specification).then(resolve).catch(reject);
20✔
40
    });
21✔
41
};
21✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc