aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitermayer <mitermayer.reis@gmail.com>2020-02-13 11:30:10 +0000
committermitermayer <mitermayer.reis@gmail.com>2020-02-13 11:30:10 +0000
commit3093ca04047ac38598b515e2e62f4697174c3e0e (patch)
treebbb392361bc0bcbb4a0cbac2c97e78a53571d682
parente5824806aef1edb462faf1dc540b6538ba3acb0e (diff)
downloadvim-prettier-3093ca04047ac38598b515e2e62f4697174c3e0e.tar.xz
Including snapshots as part of assertions
- Having snapshots can help when debugging tests
-rw-r--r--tests/__snapshots__/formatting.test.js.snap255
-rw-r--r--tests/formatting.test.js6
2 files changed, 261 insertions, 0 deletions
diff --git a/tests/__snapshots__/formatting.test.js.snap b/tests/__snapshots__/formatting.test.js.snap
new file mode 100644
index 0000000..67cd15b
--- /dev/null
+++ b/tests/__snapshots__/formatting.test.js.snap
@@ -0,0 +1,255 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Prettier formats foo.css file with :Prettier command 1`] = `
+".redClass {
+ background: \\"red\\";
+}
+#redId {
+ background: \\"red\\";
+}"
+`;
+
+exports[`Prettier formats foo.css file with :PrettierAsync command 1`] = `
+".redClass {
+ background: \\"red\\";
+}
+#redId {
+ background: \\"red\\";
+}"
+`;
+
+exports[`Prettier formats foo.graphql file with :Prettier command 1`] = `
+"{
+ baz {
+ blah
+ ...name
+ }
+ bean {
+ foo
+ blah
+ bleh
+ }
+ bar {
+ ...name
+ }
+}"
+`;
+
+exports[`Prettier formats foo.graphql file with :PrettierAsync command 1`] = `
+"{
+ baz {
+ blah
+ ...name
+ }
+ bean {
+ foo
+ blah
+ bleh
+ }
+ bar {
+ ...name
+ }
+}"
+`;
+
+exports[`Prettier formats foo.html file with :Prettier command 1`] = `
+"<html>
+ <head>
+ <title>foo</title>
+ </head>
+ <body>
+ <h1>foo</h1>
+ </body>
+</html>"
+`;
+
+exports[`Prettier formats foo.html file with :PrettierAsync command 1`] = `
+"<html>
+ <head>
+ <title>foo</title>
+ </head>
+ <body>
+ <h1>foo</h1>
+ </body>
+</html>"
+`;
+
+exports[`Prettier formats foo.js file with :Prettier command 1`] = `
+"const a = () => {
+ return 2;
+};"
+`;
+
+exports[`Prettier formats foo.js file with :PrettierAsync command 1`] = `
+"const a = () => {
+ return 2;
+};"
+`;
+
+exports[`Prettier formats foo.json file with :Prettier command 1`] = `
+"{
+ \\"name\\": \\"foo\\",
+ \\"bar\\": \\"baz\\"
+}"
+`;
+
+exports[`Prettier formats foo.json file with :PrettierAsync command 1`] = `
+"{
+ \\"name\\": \\"foo\\",
+ \\"bar\\": \\"baz\\"
+}"
+`;
+
+exports[`Prettier formats foo.less file with :Prettier command 1`] = `
+".redClass {
+ background: \\"red\\";
+}
+#redId {
+ background: \\"red\\";
+}"
+`;
+
+exports[`Prettier formats foo.less file with :PrettierAsync command 1`] = `
+".redClass {
+ background: \\"red\\";
+}
+#redId {
+ background: \\"red\\";
+}"
+`;
+
+exports[`Prettier formats foo.md file with :Prettier command 1`] = `
+"## foo
+
+Lorem ipsum dolor amet
+
+### bar
+
+- a
+- b
+- c"
+`;
+
+exports[`Prettier formats foo.md file with :PrettierAsync command 1`] = `
+"## foo
+
+Lorem ipsum dolor amet
+
+### bar
+
+- a
+- b
+- c"
+`;
+
+exports[`Prettier formats foo.php file with :Prettier command 1`] = `
+"<?php
+$a = 'a';
+
+$b = $a . $a . ' asda';"
+`;
+
+exports[`Prettier formats foo.php file with :PrettierAsync command 1`] = `
+"<?php
+$a = 'a';
+
+$b = $a . $a . ' asda';"
+`;
+
+exports[`Prettier formats foo.scss file with :Prettier command 1`] = `
+".redClass {
+ background: \\"red\\";
+}
+#redId {
+ background: \\"red\\";
+}"
+`;
+
+exports[`Prettier formats foo.scss file with :PrettierAsync command 1`] = `
+".redClass {
+ background: \\"red\\";
+}
+#redId {
+ background: \\"red\\";
+}"
+`;
+
+exports[`Prettier formats foo.ts file with :Prettier command 1`] = `
+"const a: () => number = () => {
+ return 2;
+};"
+`;
+
+exports[`Prettier formats foo.ts file with :PrettierAsync command 1`] = `
+"const a: () => number = () => {
+ return 2;
+};"
+`;
+
+exports[`Prettier formats foo.vue file with :Prettier command 1`] = `
+"<template>
+ <div class=\\"example\\">{{ msg }}</div>
+</template>
+
+<script>
+export default {
+ data() {
+ return { msg: \\"Hello world!\\" };
+ }
+};
+</script>
+
+<style>
+.example {
+ color: red;
+}
+</style>
+
+<custom1>
+ This could be e.g. documentation for the component.
+</custom1>"
+`;
+
+exports[`Prettier formats foo.vue file with :PrettierAsync command 1`] = `
+"<template>
+ <div class=\\"example\\">{{ msg }}</div>
+</template>
+
+<script>
+export default {
+ data() {
+ return { msg: \\"Hello world!\\" };
+ }
+};
+</script>
+
+<style>
+.example {
+ color: red;
+}
+</style>
+
+<custom1>
+ This could be e.g. documentation for the component.
+</custom1>"
+`;
+
+exports[`Prettier formats foo.yaml file with :Prettier command 1`] = `
+"foo:
+ bar:
+ baz:
+ bleh: ./foo
+ foobar: foobar
+ args:
+ buildno: 1"
+`;
+
+exports[`Prettier formats foo.yaml file with :PrettierAsync command 1`] = `
+"foo:
+ bar:
+ baz:
+ bleh: ./foo
+ foobar: foobar
+ args:
+ buildno: 1"
+`;
diff --git a/tests/formatting.test.js b/tests/formatting.test.js
index 6514fec..2a3e373 100644
--- a/tests/formatting.test.js
+++ b/tests/formatting.test.js
@@ -54,6 +54,9 @@ const assertFormatting = (file) => {
// we now check that we have indeed formatted the code
expect(updatedLines).not.toBe(lines);
+
+ // check snapshot
+ expect(updatedLines).toMatchSnapshot();
});
test(`Prettier formats ${filename} file with :PrettierAsync command`, async () => {
@@ -76,6 +79,9 @@ const assertFormatting = (file) => {
// we now check that we have indeed formatted the code
expect(lines).not.toBe(updatedLines);
+
+ // check snapshot
+ expect(updatedLines).toMatchSnapshot();
});
};