-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
import { createLocalVue, mount } from '@vue/test-utils' | ||
import { BootstrapVue } from 'bootstrap-vue' | ||
import { createLocalVue, shallowMount } from '@vue/test-utils' | ||
import { BootstrapVue, BSpinner } from 'bootstrap-vue' | ||
import BootstrapVueTimeline from '../bootstrap-vue-timeline.vue' | ||
|
||
const sampleItems = [ | ||
{ | ||
timestamp: Date.parse('2021-01-28T20:20:46.123Z'), | ||
title: 'title 1', | ||
content: 'content 1', | ||
link: 'link 1' | ||
content: 'content 1' | ||
}, | ||
{ | ||
timestamp: Date.parse('2021-01-28T20:20:46.456Z'), | ||
title: 'title 2', | ||
content: 'content 2', | ||
link: 'link 1' | ||
content: 'content 2' | ||
}, | ||
{ | ||
timestamp: Date.parse('2021-01-28T20:20:46.444Z'), | ||
title: 'title 3', | ||
content: 'content 3', | ||
link: 'link 3' | ||
content: 'content 3' | ||
} | ||
] | ||
|
||
test('renders a timeline with items', () => { | ||
const localVue = createLocalVue() | ||
localVue.use(BootstrapVue) | ||
describe('bootstrap vue timeline component', () => { | ||
let localVue | ||
|
||
const wrapper = mount(BootstrapVueTimeline, { | ||
localVue, | ||
attachTo: document.body, | ||
propsData: { | ||
items: sampleItems, | ||
reverse: false | ||
} | ||
beforeEach(() => { | ||
localVue = createLocalVue() | ||
localVue.use(BootstrapVue) | ||
}) | ||
const text = wrapper.text() | ||
expect(text).toMatch(/content 1[\s\S]*content 2[\s\S]*content 3/) | ||
}) | ||
|
||
test('renders a timeline with items in reversed order', () => { | ||
const localVue = createLocalVue() | ||
localVue.use(BootstrapVue) | ||
test('renders a timeline with items in reversed order', () => { | ||
const wrapper = shallowMount(BootstrapVueTimeline, { | ||
localVue, | ||
propsData: { | ||
items: sampleItems, | ||
reverse: true | ||
} | ||
}) | ||
const text = wrapper.text() | ||
expect(text).toMatch(/content 3[\s\S]*content 2[\s\S]*content 1/) | ||
}) | ||
|
||
test('renders a timeline with items with a spinner', () => { | ||
const wrapper = shallowMount(BootstrapVueTimeline, { | ||
localVue, | ||
propsData: { | ||
items: sampleItems, | ||
reverse: false, | ||
loading: true | ||
} | ||
}) | ||
const text = wrapper.text() | ||
expect(text).toMatch(/content 1[\s\S]*content 2[\s\S]*content 3/) | ||
|
||
const wrapper = mount(BootstrapVueTimeline, { | ||
localVue, | ||
attachTo: document.body, | ||
propsData: { | ||
items: sampleItems, | ||
reverse: true | ||
} | ||
const spinner = wrapper.findComponent(BSpinner) | ||
expect(spinner.exists()).toBe(true) | ||
}) | ||
const text = wrapper.text() | ||
expect(text).toMatch(/content 3[\s\S]*content 2[\s\S]*content 1/) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters