Skip to content

Commit

Permalink
style: fix lints (#1326)
Browse files Browse the repository at this point in the history
Signed-off-by: JP-Ellis <[email protected]>
  • Loading branch information
JP-Ellis authored Dec 16, 2024
1 parent d6ee658 commit ab785a4
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Request', () => {
expect(r).to.be.fulfilled,
]);
});

it('resolves when request succeeds with response body', () => {
const body = 'body';
nock(url).get('/').reply(200, body);
Expand All @@ -40,6 +41,7 @@ describe('Request', () => {
expect(p).to.eventually.be.equal(body),
]);
});

it('rejects when request fails with error message', () => {
const error = 'error';
nock(url).get('/').reply(400, error);
Expand Down
4 changes: 4 additions & 0 deletions src/dsl/graphql.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ describe('GraphQLInteraction', () => {
expect(json.request.body.operationName).to.eq('query');
});
});

describe('when given an invalid operation', () => {
it('fails with an error', () => {
expect(interaction.withOperation.bind('aoeu')).to.throw(Error);
});
});

describe('when given a null operation', () => {
it('creates a GrphQL Interaction', () => {
interaction.uponReceiving('a request');
Expand Down Expand Up @@ -79,6 +81,7 @@ describe('GraphQLInteraction', () => {
expect(json.request.body.variables).to.deep.eq({ foo: 'bar' });
});
});

describe('when no variables are provided', () => {
it('does not add the variables property to the payload', () => {
interaction.uponReceiving('a request');
Expand All @@ -97,6 +100,7 @@ describe('GraphQLInteraction', () => {
expect(json.request.body).to.not.have.property('variables');
});
});

describe('when an empty variables object is presented', () => {
it('adds the variables property to the payload', () => {
interaction.uponReceiving('a request');
Expand Down
1 change: 1 addition & 0 deletions src/dsl/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Interaction', () => {
const actual = new Interaction().uponReceiving('r').given('').state;
expect(actual).to.eql({ description: 'r' });
});

it('creates Interaction when nothing is passed', () => {
const actual = new Interaction().uponReceiving('r').state;
expect(actual).to.eql({ description: 'r' });
Expand Down
17 changes: 17 additions & 0 deletions src/dsl/matchers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe('Matcher', () => {
like({ ...r });
like(Object.freeze(f));
});

it('compiles when InterfaceToTemplate is used', () => {
const template: InterfaceToTemplate<ExampleInterface> = {
someArray: ['one', 'two'],
Expand All @@ -85,6 +86,7 @@ describe('Matcher', () => {
const unused: AnyTemplate = like(template);
});
});

describe('with types', () => {
it('compiles', () => {
const template: ExampleType = {
Expand Down Expand Up @@ -123,6 +125,7 @@ describe('Matcher', () => {
);
});
});

describe('and a failing example', () => {
it('returns false', () => {
expect(validateExample('not a date', ISO8601_DATE_FORMAT)).to.eql(
Expand All @@ -131,6 +134,7 @@ describe('Matcher', () => {
});
});
});

describe('when given an invalid regex', () => {
it('returns an error', () => {
expect(() => {
Expand Down Expand Up @@ -473,6 +477,7 @@ describe('Matcher', () => {
expect(email()).to.be.an('object');
});
});

describe('when given an invalid Email address', () => {
it('returns an error', () => {
expect(() => {
Expand All @@ -489,6 +494,7 @@ describe('Matcher', () => {
expect(uuid()).to.be.an('object');
});
});

describe('when given an invalid UUID', () => {
it('returns an error', () => {
expect(() => {
Expand All @@ -505,6 +511,7 @@ describe('Matcher', () => {
expect(ipv4Address()).to.be.an('object');
});
});

describe('when given an invalid ipv4Address', () => {
it('returns an error', () => {
expect(() => {
Expand All @@ -524,6 +531,7 @@ describe('Matcher', () => {
expect(ipv6Address()).to.be.an('object');
});
});

describe('when given an invalid ipv6Address', () => {
it('returns an error', () => {
expect(() => {
Expand All @@ -540,6 +548,7 @@ describe('Matcher', () => {
expect(hexadecimal()).to.be.an('object');
});
});

describe('when given an invalid hexadecimal', () => {
it('returns an error', () => {
expect(() => {
Expand All @@ -555,10 +564,12 @@ describe('Matcher', () => {
expect(boolean()).to.be.an('object');
expect(boolean().value).to.equal(true);
});

it('sets value=false', () => {
expect(boolean(false)).to.be.an('object');
expect(boolean(false).value).to.equal(false);
});

it('sets value=true', () => {
expect(boolean(true)).to.be.an('object');
expect(boolean(true).value).to.equal(true);
Expand Down Expand Up @@ -606,6 +617,7 @@ describe('Matcher', () => {
expect(rfc1123Timestamp()).to.be.an('object');
});
});

describe('when given an invalid rfc1123Timestamp', () => {
it('returns an error', () => {
expect(() => {
Expand All @@ -622,6 +634,7 @@ describe('Matcher', () => {
expect(iso8601Time()).to.be.an('object');
});
});

describe('when given an invalid iso8601Time', () => {
it('returns an error', () => {
expect(() => {
Expand All @@ -638,6 +651,7 @@ describe('Matcher', () => {
expect(iso8601Date()).to.be.an('object');
});
});

describe('when given an invalid iso8601Date', () => {
it('returns an error', () => {
expect(() => {
Expand All @@ -656,6 +670,7 @@ describe('Matcher', () => {
expect(iso8601DateTime()).to.be.an('object');
});
});

describe('when given an invalid iso8601DateTime', () => {
it('returns an error', () => {
expect(() => {
Expand Down Expand Up @@ -683,6 +698,7 @@ describe('Matcher', () => {
expect(iso8601DateTimeWithMillis()).to.be.an('object');
});
});

describe('when given an invalid iso8601DateTimeWithMillis', () => {
it('returns an error', () => {
expect(() => {
Expand Down Expand Up @@ -771,6 +787,7 @@ describe('Matcher', () => {
expect(extractPayload(matcher)).to.eql(expected);
});
});

describe('when given a complex nested object with matchers', () => {
it('removes all matching guff', () => {
const o = somethingLike({
Expand Down
2 changes: 2 additions & 0 deletions src/dsl/verifier/proxy/stateHandler/setupStates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ describe('#setupStates', () => {
expect(executed).to.be.true;
});
});

describe('that do not return a value', () => {
it('executes the handler and returns an empty Promise', async () => {
await setupStates(state, opts);

expect(executed).to.be.true;
});
});

describe('that specify a setup and teardown function', () => {
it('executes the lifecycle specific handler and returns any provider state injected values', async () => {
const res = await setupStates(state2, opts);
Expand Down
2 changes: 2 additions & 0 deletions src/httpPact/ffi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('Pact FFI', () => {
expect(queryMock.calledWith('foo', 1, 'baz'));
});
});

describe('with single values', () => {
it('calls the query ffi function for each value', () => {
const queryMock = sinon.stub();
Expand All @@ -64,6 +65,7 @@ describe('Pact FFI', () => {
expect(queryMock.calledWith('foo', 0, 'bar'));
});
});

describe('with array and single values', () => {
it('calls the query ffi function for each value', () => {
const queryMock = sinon.stub();
Expand Down
3 changes: 3 additions & 0 deletions src/messageConsumerPact.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ describe('MessageConsumer', () => {
}).to.throw(Error);
});
});

describe('when an empty content object has been given', () => {
it('it should throw an error', () => {
expect(() => {
consumer.withContent({});
}).to.throw(Error);
});
});

describe('when an empty metadata object has been given', () => {
it('it should throw an error', () => {
expect(() => {
Expand Down Expand Up @@ -96,6 +98,7 @@ describe('MessageConsumer', () => {
return expect(hFn(testMessage)).to.eventually.be.fulfilled;
});
});

describe('when given a function that throws an Exception', () => {
it('returns a Handler object that returns a rejected promise', () => {
const failFn = () => Promise.reject(new Error('fail'));
Expand Down
7 changes: 7 additions & 0 deletions src/messageProviderPact.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('MesageProvider', () => {
expect(provider).to.be.a('object');
expect(provider).to.respondTo('verify');
});

it('creates a Provider with default log level if not specified', () => {
provider = new MessageProviderPact({
messageProviders: {},
Expand All @@ -82,6 +83,7 @@ describe('MesageProvider', () => {
setupVerificationHandler(req, res);
});
});

describe('when their is an invalid setup', () => {
it('creates a valid express handler that rejects the message', (done) => {
const setupVerificationHandler = (
Expand Down Expand Up @@ -112,6 +114,7 @@ describe('MesageProvider', () => {
);
});
});

describe('when given a handler that does not exist', () => {
it('returns a failed promise', () => {
const findHandler = (provider as any).findHandler.bind(provider);
Expand All @@ -128,6 +131,7 @@ describe('MesageProvider', () => {
'yay',
]);
});

it('passes params to the handler', () => {
const setupStates = (provider as any).setupStates.bind(provider);
return expect(
Expand All @@ -141,6 +145,7 @@ describe('MesageProvider', () => {
]);
});
});

describe('when given a state that does not have a handler', () => {
it('returns an empty promise', () => {
provider = new MessageProviderPact({
Expand All @@ -164,6 +169,7 @@ describe('MesageProvider', () => {
});
});
});

describe('#setupProxyServer', () => {
describe('when the http server starts up', () => {
it('returns a resolved promise', () => {
Expand All @@ -173,6 +179,7 @@ describe('MesageProvider', () => {
});
});
});

describe('#setupProxyApplication', () => {
it('returns a valid express app', () => {
const setupProxyApplication = (
Expand Down
1 change: 1 addition & 0 deletions src/v3/matchers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ describe('V3 Matchers', () => {
expect(MatchersV3.reify(matcher)).to.eql(expected);
});
});

describe('when given a complex nested object with matchers', () => {
it('removes all matching guff', () => {
const o = MatchersV3.like({
Expand Down
1 change: 1 addition & 0 deletions src/v3/xml/xmlElement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe('xml element', () => {
expect(child.matcher?.['pact:matcher:type']).not.to.be.empty;
}
});

it('sets content to an empty string if the Matcher has no value', () => {
function noValueMatcher(): Matcher<string> {
return {
Expand Down

0 comments on commit ab785a4

Please sign in to comment.