Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Commit

Permalink
W.I.P.
Browse files Browse the repository at this point in the history
  • Loading branch information
pierce-h committed Aug 21, 2020
1 parent 49e544f commit e059320
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/test-app/runner/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ const createShipmentDomesticTestParamsSchema = Joi.object({
});

const testsSchema = Joi.object({
createShipment_domestic: createShipmentDomesticTestParamsSchema,
createShipment_domestic: Joi.alternatives().conditional(Joi.array(), {
then: Joi.array().items(createShipmentDomesticTestParamsSchema),
otherwise: createShipmentDomesticTestParamsSchema,
}),
createShipment_international: Joi.any().optional(),
createShipment_multi_package: Joi.any().optional(),
createShipment_with_insurance: Joi.any().optional(),
Expand Down
131 changes: 131 additions & 0 deletions test/specs/core/test-app/runner/validate-config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,136 @@ describe("validateConfig", () => {
expect(result).to.be.undefined;
expect(errorResult.message).to.be.equal("tests.createShipment_domestic.session must be of type object");
});

it("validates that connectArgs is an object", () => {
const config = {
tests: {
createShipment_domestic: {
connectArgs: "invalid"
},
},
};
let result, errorResult;

try {
result = validateConfig(config);
}
catch (error) {
errorResult = error;
}

expect(result).to.be.undefined;
expect(errorResult.message).to.be.equal("tests.createShipment_domestic.connectArgs must be of type object");
});
});

describe("tests.createShipment_domestic when given an array", () => {
it("validates that retries is a number", () => {
const config = {
tests: {
createShipment_domestic: [{
retries: "invalid"
}]
},
};

let result, errorResult;

try {
result = validateConfig(config);
}
catch (error) {
errorResult = error;
}

expect(result).to.be.undefined;
expect(errorResult.message).to.be.equal("tests.createShipment_domestic[0].retries must be a number");
});

it("validates that timeout is a number", () => {
const config = {
tests: {
createShipment_domestic: [{
timeout: "invalid"
}]
},
};

let result, errorResult;

try {
result = validateConfig(config);
}
catch (error) {
errorResult = error;
}

expect(result).to.be.undefined;
expect(errorResult.message).to.be.equal("tests.createShipment_domestic[0].timeout must be a number");
});

it("validates that skip is a boolean", () => {
const config = {
tests: {
createShipment_domestic: [{
skip: "invalid"
}]
},
};

let result, errorResult;

try {
result = validateConfig(config);
}
catch (error) {
errorResult = error;
}

expect(result).to.be.undefined;
expect(errorResult.message).to.be.equal("tests.createShipment_domestic[0].skip must be a boolean");
});

it("validates that session is an object", () => {
const config = {
tests: {
createShipment_domestic: [{
session: "invalid"
}]
},
};
let result, errorResult;

try {
result = validateConfig(config);
}
catch (error) {
errorResult = error;
}

expect(result).to.be.undefined;
expect(errorResult.message).to.be.equal("tests.createShipment_domestic[0].session must be of type object");
});

it("validates that connectArgs is an object", () => {
const config = {
tests: {
createShipment_domestic: [{
connectArgs: "invalid"
}]
},
};
let result, errorResult;

try {
result = validateConfig(config);
}
catch (error) {
errorResult = error;
}

expect(result).to.be.undefined;
expect(errorResult.message).to.be.equal("tests.createShipment_domestic[0].connectArgs must be of type object");
});
});
});

0 comments on commit e059320

Please sign in to comment.