resume-cli 3.0.2 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/validate.js DELETED
@@ -1,15 +0,0 @@
1
- import { promisify } from 'util';
2
- import ZSchema from 'z-schema';
3
- import ZSchemaErrors from 'z-schema-errors';
4
-
5
- const reporter = ZSchemaErrors.init();
6
- const validator = new ZSchema();
7
- const validate = promisify((...args) => validator.validate(...args)); // maintains context
8
-
9
- export default async ({ resume, schema }) => {
10
- try {
11
- return await validate(resume, schema);
12
- } catch (errors) {
13
- throw new Error(reporter.extractMessage({ report: { errors } }));
14
- }
15
- };
@@ -1,33 +0,0 @@
1
- import validate from './validate';
2
- import getSchema from './get-schema';
3
-
4
- describe('validate', () => {
5
- let defaultSchema;
6
- beforeEach(async () => {
7
- defaultSchema = await getSchema();
8
- });
9
- it('should not throw an error for a valid resume object', async () => {
10
- await validate({ resume: { basics: {} }, schema: defaultSchema });
11
- });
12
- it('should throw an error for an invalid resume object', async () => {
13
- await expect(
14
- validate({ resume: { notInTheSchema: true }, schema: defaultSchema }),
15
- ).rejects.toMatchInlineSnapshot(
16
- `[Error: An error occurred 'Additional properties not allowed: notInTheSchema'.]`,
17
- );
18
- });
19
- it('should accept a schema override', async () => {
20
- await validate({
21
- resume: 123,
22
- schema: { type: 'number' },
23
- });
24
- await expect(
25
- validate({
26
- resume: 'thomas',
27
- schema: { type: 'number' },
28
- }),
29
- ).rejects.toMatchInlineSnapshot(
30
- `[Error: An error occurred 'Expected type number but found type string'.]`,
31
- );
32
- });
33
- });