From 1f7385da36034425b3ff8200384da6bfdc6b6f73 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Wed, 12 Jun 2019 19:45:25 -0700 Subject: [PATCH] Changes files --- CNAME | 1 - assets/App.spec.js | 45 +++++++++++++++++++ assets/__snapshots__/App.spec.js.snap | 63 +++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) delete mode 100644 CNAME create mode 100644 assets/App.spec.js create mode 100644 assets/__snapshots__/App.spec.js.snap diff --git a/CNAME b/CNAME deleted file mode 100644 index a5e22dbb..00000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -dozzle.dev \ No newline at end of file diff --git a/assets/App.spec.js b/assets/App.spec.js new file mode 100644 index 00000000..c386e616 --- /dev/null +++ b/assets/App.spec.js @@ -0,0 +1,45 @@ +import fetchMock from "fetch-mock"; +import EventSource from "eventsourcemock"; +import { shallowMount, RouterLinkStub } from "@vue/test-utils"; +import App from "./App"; + +describe("", () => { + const stubs = { RouterLink: RouterLinkStub, "router-view": true }; + beforeEach(() => { + global.BASE_PATH = ""; + global.EventSource = EventSource; + fetchMock.getOnce("/api/containers.json", [{ id: "abc", name: "Test 1" }, { id: "xyz", name: "Test 2" }]); + }); + afterEach(() => fetchMock.reset()); + + test("is a Vue instance", async () => { + const wrapper = shallowMount(App, { stubs }); + expect(wrapper.isVueInstance()).toBeTruthy(); + }); + + test("has right title", async () => { + const wrapper = shallowMount(App, { stubs }); + await fetchMock.flush(); + expect(wrapper.vm.title).toContain("2 containers"); + }); + + test("renders correctly", async () => { + const wrapper = shallowMount(App, { stubs }); + await fetchMock.flush(); + expect(wrapper.element).toMatchSnapshot(); + }); + + test("renders router-link correctly", async () => { + const wrapper = shallowMount(App, { stubs }); + await fetchMock.flush(); + expect(wrapper.find(RouterLinkStub).props().to).toMatchInlineSnapshot(` + Object { + "name": "container", + "params": Object { + "id": "abc", + "name": "Test 1", + }, + } + `); + }); +}); diff --git a/assets/__snapshots__/App.spec.js.snap b/assets/__snapshots__/App.spec.js.snap new file mode 100644 index 00000000..b95ab138 --- /dev/null +++ b/assets/__snapshots__/App.spec.js.snap @@ -0,0 +1,63 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` renders correctly 1`] = ` +
+ + +
+ +
+
+`;