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

Commit

Permalink
fix unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
lookacat committed Jan 7, 2022
1 parent 92771ba commit 0719e32
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 58 deletions.
50 changes: 0 additions & 50 deletions src/components/atoms/OcResourceName/OcResourceName.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,6 @@ const extension = "jpg"
const type = "file"

describe("OcResourceName", () => {
it("displays full path", () => {
const wrapper = shallowMount(Name, {
propsData: {
fullPath,
isPathDisplayed: true,
name,
extension,
type,
},
})

expect(wrapper.find(".oc-resource-path").text()).toMatch("…/nature/")
expect(wrapper.find(".oc-resource-basename").text()).toMatch("forest")
expect(wrapper.find(".oc-resource-extension").text()).toMatch(".jpg")
expect(wrapper).toMatchSnapshot()
})

it("displays only direct parent", () => {
const wrapper = shallowMount(Name, {
propsData: {
fullPath: "Documents/notes.txt",
isPathDisplayed: true,
name: "notes.txt",
extension: "txt",
type: "file",
},
})

expect(wrapper.find(".oc-resource-path").text()).toMatch("Documents/")
expect(wrapper.find(".oc-resource-basename").text()).toMatch("notes")
expect(wrapper.find(".oc-resource-extension").text()).toMatch(".txt")
expect(wrapper).toMatchSnapshot()
})

it("hides the path if not enabled", () => {
const wrapper = shallowMount(Name, {
propsData: {
fullPath,
name,
extension,
type,
},
})

expect(wrapper.find(".oc-resource-path").exists()).toBeFalsy()
expect(wrapper.find(".oc-resource-basename").text()).toMatch("forest")
expect(wrapper.find(".oc-resource-extension").text()).toMatch(".jpg")
expect(wrapper).toMatchSnapshot()
})

it("doesn't add extension to hidden folder", () => {
const wrapper = shallowMount(Name, {
propsData: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`OcResourceName displays full path 1`] = `<span data-test-resource-path="images/nature/forest.jpg" data-test-resource-name="…/nature/forest.jpg" data-test-resource-type="file" class="oc-resource-name"><span class="oc-text-truncate"><span class="oc-resource-path">…/nature/</span><span class="oc-resource-basename">forest</span></span> <span class="oc-resource-extension">.jpg</span></span>`;

exports[`OcResourceName displays only direct parent 1`] = `<span data-test-resource-path="Documents/notes.txt" data-test-resource-name="Documents/notes.txt" data-test-resource-type="file" class="oc-resource-name"><span class="oc-text-truncate"><span class="oc-resource-path">Documents/</span><span class="oc-resource-basename">notes</span></span> <span class="oc-resource-extension">.txt</span></span>`;

exports[`OcResourceName doesn't add extension to hidden folder 1`] = `
<span data-test-resource-path=".hidden" data-test-resource-name=".hidden" data-test-resource-type="folder" class="oc-resource-name"><span class="oc-text-truncate"><!----><span class="oc-resource-basename">.hidden</span></span>
<span data-test-resource-path=".hidden" data-test-resource-name=".hidden" data-test-resource-type="folder" class="oc-resource-name"><span class="oc-text-truncate"><span class="oc-resource-basename">.hidden</span></span>
<!----></span>
`;

exports[`OcResourceName hides the path if not enabled 1`] = `<span data-test-resource-path="images/nature/forest.jpg" data-test-resource-name="forest.jpg" data-test-resource-type="file" class="oc-resource-name"><span class="oc-text-truncate"><!----><span class="oc-resource-basename">forest</span></span> <span class="oc-resource-extension">.jpg</span></span>`;

exports[`OcResourceName renders folder names with dots completely in the basename 1`] = `
<span data-test-resource-path="folder.with.dots" data-test-resource-name="folder.with.dots" data-test-resource-type="folder" class="oc-resource-name"><span class="oc-text-truncate"><!----><span class="oc-resource-basename">folder.with.dots</span></span>
<span data-test-resource-path="folder.with.dots" data-test-resource-name="folder.with.dots" data-test-resource-type="folder" class="oc-resource-name"><span class="oc-text-truncate"><span class="oc-resource-basename">folder.with.dots</span></span>
<!----></span>
`;

0 comments on commit 0719e32

Please sign in to comment.