Skip to content

Commit

Permalink
update all tests to use compacted format
Browse files Browse the repository at this point in the history
  • Loading branch information
pospi committed Dec 11, 2019
1 parent 926d995 commit 73329d7
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 212 deletions.
88 changes: 30 additions & 58 deletions src/components/Kanban.stories.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,37 @@
import { storiesOf, specs, describe, it } from '!/facade'
import { render, cleanup } from '@testing-library/svelte'
import expect from 'expect'
import { componentStories, it, render, expect } from '!/testing-framework'

import Kanban from './Kanban.svelte'
import markdownNotes from './Kanban.stories.md'

storiesOf('Kanban|Whole board', module)
componentStories('Kanban|Whole board', Kanban, module, markdownNotes)

.add('empty state',
() => {
specs(() => describe('empty state', () => {
it('should render', async () => {
expect(render(Kanban)).toBeTruthy()
cleanup()
})
}))
.add('empty state', {}, (props) => {
it('should render', async () => {
expect(render(Kanban, { props })).toBeTruthy()
})
})

return {
Component: Kanban,
props: {
.add('with tasks', {
bins: [{
title: 'first batch of tasks',
note: 'doing stuff',
due: new Date(),
cards: [{
note: 'a task that needs doing',
due: new Date(),
members: [
{ image: 'https://randomuser.me/api/portraits/women/28.jpg' },
{ image: 'https://randomuser.me/api/portraits/women/23.jpg' },
],
}],
outputs: [{
resourceClassifiedAs: {
name: 'an output resource',
},
}
},
{ notes: { markdown: markdownNotes } },
)

.add(
'with tasks',
() => {
const props = {
bins: [{
title: 'first batch of tasks',
note: 'doing stuff',
due: new Date(),
cards: [{
note: 'a task that needs doing',
due: new Date(),
members: [
{ image: 'https://randomuser.me/api/portraits/women/28.jpg' },
{ image: 'https://randomuser.me/api/portraits/women/23.jpg' },
],
}],
outputs: [{
resourceClassifiedAs: {
name: 'an output resource',
},
}],
}],
}

specs(() => describe('with tasks', () => {
it('should render', async () => {
expect(render(Kanban, { props })).toBeTruthy()
cleanup()
})
}))

return {
Component: Kanban,
props,
}
},
{ notes: { markdown: markdownNotes } },
)
}],
}],
}, (props) => {
it('should render', async () => {
expect(render(Kanban, { props })).toBeTruthy()
})
})
82 changes: 26 additions & 56 deletions src/components/kanban/Bin.stories.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,30 @@
import { storiesOf, specs, describe, it } from '!/facade'
import { render, cleanup } from '@testing-library/svelte'
import expect from 'expect'
import { componentStories, it, render, expect } from '!/testing-framework'

import Bin from './Bin.svelte'
import markdownNotes from './Bin.stories.md'

storiesOf('Kanban|Task batch', module)

.add(
'empty state',
() => {
const props = {
title: 'an empty task bin',
}

specs(() => describe('empty state', () => {
it('should render', async () => {
expect(render(Bin, { props })).toBeTruthy()
cleanup()
})
}))

return {
Component: Bin,
props,
}
},
{ notes: { markdown: markdownNotes } },
)

.add(
'with cards',
() => {
const props = {
title: 'bin with cards',
cards: [
{
members: [{ image: 'https://randomuser.me/api/portraits/women/28.jpg' }],
due: new Date(),
note: 'need to do a thing',
title: 'first task',
},
],
}

specs(() => describe('with cards', () => {
it('should render', async () => {
expect(render(Bin, { props })).toBeTruthy()
cleanup()
})
}))

return {
Component: Bin,
props,
}
},
{ notes: { markdown: markdownNotes } },
)
componentStories('Kanban|Task batch', Bin, module, markdownNotes)

.add('empty state', {
title: 'an empty task bin',
}, (props) => {
it('should render', async () => {
expect(render(Bin, { props })).toBeTruthy()
})
})

.add('with cards', {
title: 'bin with cards',
cards: [
{
members: [{ image: 'https://randomuser.me/api/portraits/women/28.jpg' }],
due: new Date(),
note: 'need to do a thing',
title: 'first task',
},
],
}, (props) => {
it('should render', async () => {
expect(render(Bin, { props })).toBeTruthy()
})
})
65 changes: 19 additions & 46 deletions src/components/kanban/bin/Card.stories.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,25 @@
import { storiesOf, specs, describe, it } from '!/facade'
import { render, cleanup } from '@testing-library/svelte'
import expect from 'expect'
import { componentStories, it, render, expect } from '!/testing-framework'

import Card from './Card.svelte'
import markdownNotes from './Card.stories.md'

storiesOf('Kanban|Task card', module)
componentStories('Kanban|Task card', Card, module, markdownNotes)

.add(
'empty state',
() => {
specs(() => describe('empty state', () => {
it('should render', async () => {
expect(render(Card)).toBeTruthy()
cleanup()
})
}))
.add('empty state', {}, (props) => {
it('should render', async () => {
expect(render(Card, { props })).toBeTruthy()
})
})

return {
Component: Card,
}
},
{ notes: { markdown: markdownNotes } },
)

.add(
'with linked task',
() => {
const props = {
note: 'a task that needs doing',
due: new Date(),
members: [
{ image: 'https://randomuser.me/api/portraits/women/28.jpg' },
{ image: 'https://randomuser.me/api/portraits/women/23.jpg' },
],
}

specs(() => describe('with linked task', () => {
it('should render', async () => {
expect(render(Card, { props })).toBeTruthy()
cleanup()
})
}))

return {
Component: Card,
props,
}
},
{ notes: { markdown: markdownNotes } },
)
.add('with linked task', {
note: 'a task that needs doing',
due: new Date(),
members: [
{ image: 'https://randomuser.me/api/portraits/women/28.jpg' },
{ image: 'https://randomuser.me/api/portraits/women/23.jpg' },
],
}, (props) => {
it('should render', async () => {
expect(render(Card, { props })).toBeTruthy()
})
})
77 changes: 25 additions & 52 deletions src/components/kanban/bin/Output.stories.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,31 @@
import { storiesOf, specs, describe, it } from '!/facade'
import { render, cleanup } from '@testing-library/svelte'
import expect from 'expect'
import { componentStories, it, render, expect } from '!/testing-framework'

import Output from './Output.svelte'
import markdownNotes from './Output.stories.md'

storiesOf('Kanban|Batch output', module)
componentStories('Kanban|Batch output', Output, module, markdownNotes)

.add(
'empty state',
() => {
specs(() => describe('empty state', () => {
it('should render', async () => {
expect(render(Output)).toBeTruthy()
cleanup()
})
}))
.add('empty state', {}, (props) => {
it('should render', async () => {
expect(render(Output, { props })).toBeTruthy()
})
})

return {
Component: Output,
}
},
{ notes: { markdown: markdownNotes } },
)

.add(
'with output resources',
() => {
const props = {
outputs: [
{
resourceClassifiedAs: {
name: 'an output resource',
},
},
{
resourceClassifiedAs: {
name: 'another output resource',
},
},
],
}

specs(() => describe('with output resources', () => {
it('should render', async () => {
expect(render(Output, { props })).toBeTruthy()
cleanup()
})
}))

return {
Component: Output,
props,
}
},
{ notes: { markdown: markdownNotes } },
)
.add('with output resources', {
outputs: [
{
resourceClassifiedAs: {
name: 'an output resource',
},
},
{
resourceClassifiedAs: {
name: 'another output resource',
},
},
],
}, (props) => {
it('should render', async () => {
expect(render(Output, { props })).toBeTruthy()
})
})

0 comments on commit 73329d7

Please sign in to comment.