jsfmt.spec.js.snap 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. // Jest Snapshot v1, https://goo.gl/fbAQLP
  2. exports[`backticks.js 1`] = `
  3. gql\`
  4. "\\\`foo\\\` mutation payload."
  5. type FooPayload {
  6. bar: String
  7. }
  8. \`
  9. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. gql\`
  11. "\\\`foo\\\` mutation payload."
  12. type FooPayload {
  13. bar: String
  14. }
  15. \`;
  16. `;
  17. exports[`comment-tag.js 1`] = `
  18. const query = /* GraphQL */\`
  19. {
  20. user( id : 5 ) {
  21. firstName
  22. lastName
  23. }
  24. }
  25. \`;
  26. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. const query = /* GraphQL */ \`
  28. {
  29. user(id: 5) {
  30. firstName
  31. lastName
  32. }
  33. }
  34. \`;
  35. `;
  36. exports[`definitions.js 1`] = `
  37. graphql\`
  38. fragment x on y {
  39. z
  40. }
  41. fragment a on b {
  42. c
  43. }
  44. \`;
  45. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. graphql\`
  47. fragment x on y {
  48. z
  49. }
  50. fragment a on b {
  51. c
  52. }
  53. \`;
  54. `;
  55. exports[`expressions.js 1`] = `
  56. graphql(schema, \`
  57. query allPartsByManufacturerName($name: String!) {
  58. allParts(filter:{manufacturer: {name: $name}}) {
  59. ... PartAll
  60. }}
  61. \${fragments.all}
  62. \`)
  63. const veryLongVariableNameToMakeTheLineBreak = graphql(schema, \`
  64. query allPartsByManufacturerName($name: String!) {
  65. allParts(filter:{manufacturer: {name: $name}}) {
  66. ... PartAll
  67. }}
  68. \${fragments.all}
  69. \`)
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. graphql(
  72. schema,
  73. \`
  74. query allPartsByManufacturerName($name: String!) {
  75. allParts(filter: { manufacturer: { name: $name } }) {
  76. ...PartAll
  77. }
  78. }
  79. \${fragments.all}
  80. \`
  81. );
  82. const veryLongVariableNameToMakeTheLineBreak = graphql(
  83. schema,
  84. \`
  85. query allPartsByManufacturerName($name: String!) {
  86. allParts(filter: { manufacturer: { name: $name } }) {
  87. ...PartAll
  88. }
  89. }
  90. \${fragments.all}
  91. \`
  92. );
  93. `;
  94. exports[`graphql.js 1`] = `
  95. graphql(schema, \`
  96. mutation MarkReadNotificationMutation(
  97. $input
  98. : MarkReadNotificationData!
  99. )
  100. { markReadNotification(data: $input ) { notification {seenState} } }\`)
  101. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. graphql(
  103. schema,
  104. \`
  105. mutation MarkReadNotificationMutation($input: MarkReadNotificationData!) {
  106. markReadNotification(data: $input) {
  107. notification {
  108. seenState
  109. }
  110. }
  111. }
  112. \`
  113. );
  114. `;
  115. exports[`graphql-tag.js 1`] = `
  116. import gql from "graphql-tag";
  117. const query = gql\`
  118. {
  119. user( id : 5 ) {
  120. firstName
  121. lastName
  122. }
  123. }
  124. \`;
  125. // With interpolations:
  126. gql\`
  127. query User {
  128. user(id:5){
  129. ...UserDetails
  130. ...Friends
  131. }
  132. }
  133. \${USER_DETAILS_FRAGMENT}\${FRIENDS_FRAGMENT}
  134. \`
  135. // Skip if non-toplevel interpolation:
  136. gql\`
  137. query User {
  138. user(id:\${id}){ name }
  139. }
  140. \`
  141. // Skip if top-level interpolation within comment:
  142. gql\`
  143. query User {
  144. user(id:5){ name }
  145. }
  146. #\${test}
  147. \`
  148. // Comment on last line:
  149. gql\`
  150. query User {
  151. user(id:5){ name }
  152. }
  153. # comment\`
  154. // \` <-- editor syntax highlighting workaround
  155. // Preserve up to one blank line between things and enforce linebreak between
  156. // interpolations:
  157. gql\`
  158. # comment
  159. \${one}\${two} \${three}
  160. \${four}
  161. \${five}
  162. # comment
  163. \${six}
  164. # comment
  165. \${seven}
  166. # comment
  167. \${eight}
  168. # comment with trailing whitespace
  169. # blank line above this comment
  170. \`
  171. // Interpolation directly before and after query:
  172. gql\`\${one} query Test { test }\${two}\`
  173. // Only interpolation:
  174. gql\`\${test}\`
  175. // Only comment:
  176. gql\`# comment\`
  177. // \` <-- editor syntax highlighting workaround
  178. // Only whitespace:
  179. gql\` \`
  180. // Empty:
  181. gql\`\`
  182. // Comments after other things:
  183. // Currently, comments after interpolations are moved to the next line.
  184. // We might want to keep them on the next line in the future.
  185. gql\`
  186. \${test} # comment
  187. query Test { # comment
  188. test # comment
  189. } # comment
  190. \${test} # comment
  191. \${test} # comment
  192. \${test} # comment
  193. # comment
  194. \${test} # comment
  195. \`
  196. // Larger mixed test:
  197. gql\`
  198. query User {
  199. test
  200. }
  201. \${USER_DETAILS_FRAGMENT}
  202. # Comment
  203. # that continues on a new line
  204. # and has a blank line in the middle
  205. \${FRIENDS_FRAGMENT}
  206. \${generateFragment({
  207. totally: "a good idea"
  208. })}
  209. \${fragment}#comment
  210. fragment another on User { name
  211. }\${ fragment }\`
  212. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  213. import gql from "graphql-tag";
  214. const query = gql\`
  215. {
  216. user(id: 5) {
  217. firstName
  218. lastName
  219. }
  220. }
  221. \`;
  222. // With interpolations:
  223. gql\`
  224. query User {
  225. user(id: 5) {
  226. ...UserDetails
  227. ...Friends
  228. }
  229. }
  230. \${USER_DETAILS_FRAGMENT}
  231. \${FRIENDS_FRAGMENT}
  232. \`;
  233. // Skip if non-toplevel interpolation:
  234. gql\`
  235. query User {
  236. user(id:\${id}){ name }
  237. }
  238. \`;
  239. // Skip if top-level interpolation within comment:
  240. gql\`
  241. query User {
  242. user(id:5){ name }
  243. }
  244. #\${test}
  245. \`;
  246. // Comment on last line:
  247. gql\`
  248. query User {
  249. user(id: 5) {
  250. name
  251. }
  252. }
  253. # comment
  254. \`;
  255. // \` <-- editor syntax highlighting workaround
  256. // Preserve up to one blank line between things and enforce linebreak between
  257. // interpolations:
  258. gql\`
  259. # comment
  260. \${one}
  261. \${two}
  262. \${three}
  263. \${four}
  264. \${five}
  265. # comment
  266. \${six}
  267. # comment
  268. \${seven}
  269. # comment
  270. \${eight}
  271. # comment with trailing whitespace
  272. # blank line above this comment
  273. \`;
  274. // Interpolation directly before and after query:
  275. gql\`
  276. \${one}
  277. query Test {
  278. test
  279. }
  280. \${two}
  281. \`;
  282. // Only interpolation:
  283. gql\`
  284. \${test}
  285. \`;
  286. // Only comment:
  287. gql\`
  288. # comment
  289. \`;
  290. // \` <-- editor syntax highlighting workaround
  291. // Only whitespace:
  292. gql\`\`;
  293. // Empty:
  294. gql\`\`;
  295. // Comments after other things:
  296. // Currently, comments after interpolations are moved to the next line.
  297. // We might want to keep them on the next line in the future.
  298. gql\`
  299. \${test}
  300. # comment
  301. query Test {
  302. # comment
  303. test # comment
  304. } # comment
  305. \${test}
  306. # comment
  307. \${test}
  308. # comment
  309. \${test}
  310. # comment
  311. # comment
  312. \${test}
  313. # comment
  314. \`;
  315. // Larger mixed test:
  316. gql\`
  317. query User {
  318. test
  319. }
  320. \${USER_DETAILS_FRAGMENT}
  321. # Comment
  322. # that continues on a new line
  323. # and has a blank line in the middle
  324. \${FRIENDS_FRAGMENT}
  325. \${generateFragment({
  326. totally: "a good idea"
  327. })}
  328. \${fragment}
  329. #comment
  330. fragment another on User {
  331. name
  332. }
  333. \${fragment}
  334. \`;
  335. `;
  336. exports[`invalid.js 1`] = `
  337. // none of the embedded GraphQL should be formatted
  338. // for they have an invalid escape sequence
  339. gql\`
  340. "\\x"
  341. type Foo {
  342. a: string
  343. }
  344. \`;
  345. gql\`
  346. type Foo {
  347. a: string
  348. }
  349. \${stuff}
  350. "\\x"
  351. type Bar {
  352. b : string
  353. }
  354. \`;
  355. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  356. // none of the embedded GraphQL should be formatted
  357. // for they have an invalid escape sequence
  358. gql\`
  359. "\\x"
  360. type Foo {
  361. a: string
  362. }
  363. \`;
  364. gql\`
  365. type Foo {
  366. a: string
  367. }
  368. \${stuff}
  369. "\\x"
  370. type Bar {
  371. b : string
  372. }
  373. \`;
  374. `;
  375. exports[`react-relay.js 1`] = `
  376. const { graphql } = require("react-relay");
  377. graphql\`
  378. mutation MarkReadNotificationMutation(
  379. $input
  380. : MarkReadNotificationData!
  381. )
  382. { markReadNotification(data: $input ) { notification {seenState} } }
  383. \`;
  384. graphql.experimental\`
  385. mutation MarkReadNotificationMutation(
  386. $input
  387. : MarkReadNotificationData!
  388. )
  389. { markReadNotification(data: $input ) { notification {seenState} } }
  390. \`;
  391. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  392. const { graphql } = require("react-relay");
  393. graphql\`
  394. mutation MarkReadNotificationMutation($input: MarkReadNotificationData!) {
  395. markReadNotification(data: $input) {
  396. notification {
  397. seenState
  398. }
  399. }
  400. }
  401. \`;
  402. graphql.experimental\`
  403. mutation MarkReadNotificationMutation($input: MarkReadNotificationData!) {
  404. markReadNotification(data: $input) {
  405. notification {
  406. seenState
  407. }
  408. }
  409. }
  410. \`;
  411. `;