Skip to content

fix parseHydraDocumentation.test #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2018

Conversation

jfthuillier
Copy link
Contributor

No description provided.

expect(data).toHaveProperty("response");
expect(data).toHaveProperty("status");
});
let expectedError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid issue, can you initialize "expectedError.message"?

For example:

const expectedError = { message: '' }

expect(data).toHaveProperty("response");
expect(data).toHaveProperty("status");
});
let expectedError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid issue, can you initialize "expectedError.message"?

For example:

const expectedError = { message: '' }

parseHydraDocumentation("http://localhost/").catch(data => {
expect(data.message).toBe('The API entrypoint has no "@type" key.');
});
let expectedError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid issue, can you initialize "expectedError.message"?

For example:

const expectedError = { message: '' }

'The API documentation has no "http://www.w3.org/ns/hydra/core#supportedClass" key or its value is not an array.'
);
});
let expectedError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid issue, can you initialize "expectedError.message"?

For example:

const expectedError = { message: '' }

'The entrypoint definition has no "http://www.w3.org/ns/hydra/core#supportedProperty" key or it is not an array.'
);
});
let expectedError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid issue, can you initialize "expectedError.message"?

For example:

const expectedError = { message: '' }

expect(data).toHaveProperty("response");
expect(data).toHaveProperty("status");
});
const expectedError = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauchede : For this test, expectedError should be an empty object ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, an empty object should be better.

try {
await parseHydraDocumentation("http://localhost/");
} catch (error) {
expectedError.api = error.api;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the value of expectedError: it will be easier than create new properties.

expectedError = error

expect(data).toHaveProperty("response");
expect(data).toHaveProperty("status");
});
const expectedError = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, an empty object should be better.

try {
await parseHydraDocumentation("http://localhost/");
} catch (error) {
expectedError.api = error.api;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the value of expectedError: it will be easier than create new properties.

expectedError = error

test("Invalid entrypoint JSON", () => {
const entrypoint = `{foo,}`;
test("Invalid entrypoint JSON", async () => {
let entrypoint = `{foo,}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you use backquote here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change the format, but i think this is suppose to be a JSON string, not a JS Object ? (Like the const entrypoint)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I did not see than you "only" change const to let. Why did you change it (I did not see another assignation of entrypoint in the test)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To gain speed because it's one letter less 😄
(Can't remember why, i just rechanged it)

@mauchede mauchede self-assigned this Jun 13, 2018
@mauchede mauchede added the bug label Jun 13, 2018
Copy link
Contributor

@mauchede mauchede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Can you squash your commit? I will merge your PR after squashing.

@mauchede mauchede mentioned this pull request Jun 14, 2018
@jfthuillier
Copy link
Contributor Author

Commits squashed !
First PR ever 😊 🍻 🎉

@mauchede mauchede merged commit 8e90ea1 into api-platform:master Jun 15, 2018
@mauchede
Copy link
Contributor

Nice work @jfthuillier!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants