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

JSON string tests and example #112

Merged
merged 1 commit into from
May 22, 2017
Merged

Conversation

Apidcloud
Copy link
Contributor

@Apidcloud Apidcloud commented May 21, 2017

Added two tests that show the use the same JSON string on Windows and UNIX, despite not being totally sure that's how it's done. Would it be better to test against JSON.parse?

Also added a real example to the README.

I had to use the --no-verify flag, as prettier-eslint is messing up the triple backslash in the tests. What can I do to prevent that?

And just noticed that travis build is also failing precisely because of the triple backslash (lint script), despite the tests themselves running just fine.

Closes #30

@kentcdodds
Copy link
Owner

Do the tests pass without the extra slashes? I'm pretty sure the linting rule is just to say: "Hey, you don't need these slashes because the code will function exactly the same without them" but I could be wrong. I understand we'd need them in a package.json, but maybe not in that string. I could be wrong though...

Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Looks awesome other than that linting stuff :)

@@ -1,15 +1,19 @@
import isWindowsMock from 'is-windows'
import varValueConvert from './variable'

const JSON_VALUE = '{\\\"foo\\\":\\\"bar\\\"}'
Copy link
Owner

Choose a reason for hiding this comment

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

Confirmed, the slashes may be necessary in the package.json, but they're not necessary for the JS:

screen shot 2017-05-21 at 1 38 36 pm

}
```
Pay special attention to the **triple backslash** `(\\\)` **before** the **double quotes** `(")` and the **absence** of **single quotes** `(')`.
Both of these conditions have to be met in order to work both on Windows and UNIX.
Copy link
Owner

Choose a reason for hiding this comment

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

Wonderful! 👍

add working tests that use the same JSON value on both Windows and UNIX

Closes kentcdodds#30
@codecov-io
Copy link

codecov-io commented May 21, 2017

Codecov Report

Merging #112 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #112   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines          45     45           
=====================================
  Hits           45     45

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c4f346...d379311. Read the comment docs.

@Apidcloud
Copy link
Contributor Author

Alright, I have made the mentioned changes and squashed the commits. Seems good to go 👍

@kentcdodds kentcdodds merged commit c9908f3 into kentcdodds:master May 22, 2017
@kentcdodds
Copy link
Owner

Thanks so much!

@kentcdodds
Copy link
Owner

Oh, also, would you like to add yourself to the contributors table? You can feel free to do it as an additional PR :)

@Apidcloud Apidcloud deleted the pr/JSONObject branch May 23, 2017 13:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants