Skip to content

Commit

Permalink
Test pipelines order
Browse files Browse the repository at this point in the history
  • Loading branch information
pirhoo committed Mar 24, 2020
1 parent 8f8765e commit dd65f19
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/unit/specs/store/modules/pipelines.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,24 @@ describe('PipelinesStore', () => {
expect(pipelines.reduce((res, fn) => fn(res), 1)).toBe(4)
expect(pipelines.reduce((res, fn) => fn(res), 10)).toBe(40)
})

it('should have ordered pipelines', () => {
const category = 'test-category-ordered-case'
store.commit('pipelines/register', { category, type: s => s.toLowerCase() })
store.commit('pipelines/register', { category, type: s => s.toUpperCase() })
const pipelines = store.getters['pipelines/getPipelineChainByCategory'](category)
expect(pipelines).toHaveLength(2)
expect(pipelines.reduce((res, fn) => fn(res), 'foo BAR')).toBe('FOO BAR')
expect(pipelines.reduce((res, fn) => fn(res), 'FOO bar')).toBe('FOO BAR')
})

it('should have ordered pipelines', () => {
const category = 'test-category-ordered-case-with-property'
store.commit('pipelines/register', { category, type: s => s.toLowerCase(), order: 10 })
store.commit('pipelines/register', { category, type: s => s.toUpperCase(), order: 5 })
const pipelines = store.getters['pipelines/getPipelineChainByCategory'](category)
expect(pipelines).toHaveLength(2)
expect(pipelines.reduce((res, fn) => fn(res), 'foo BAR')).toBe('foo bar')
expect(pipelines.reduce((res, fn) => fn(res), 'FOO bar')).toBe('foo bar')
})
})

0 comments on commit dd65f19

Please sign in to comment.