-
Notifications
You must be signed in to change notification settings - Fork 61
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
1 parent
0cb1f6d
commit 079921c
Showing
13 changed files
with
194 additions
and
19 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
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-disable @typescript-eslint/camelcase */ | ||
|
||
export const savedQueries = [ | ||
{ | ||
refreshRate: 0, | ||
cached: false, | ||
displayName: 'purchases', | ||
name: 'purchases', | ||
tags: [], | ||
visualization: { | ||
type: 'bar', | ||
chartSettings: { | ||
layout: 'vertical', | ||
}, | ||
widgetSettings: {}, | ||
}, | ||
query: { | ||
analysis_type: 'count', | ||
}, | ||
}, | ||
]; |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-disable @typescript-eslint/camelcase */ | ||
import sagaHelper from 'redux-saga-testing'; | ||
import { select, put } from 'redux-saga/effects'; | ||
import { Layout } from '@keen.io/ui-core'; | ||
|
||
import { selectSavedQuery, updateSaveQuery } from './actions'; | ||
import { selectSavedQuery as selectSavedQueryFlow } from './saga'; | ||
|
||
import { runQuery, getSavedQueries, setQuerySettings } from '../queries'; | ||
import { setVisualization } from '../app'; | ||
|
||
import { savedQueries } from './fixtures'; | ||
|
||
import { SelectSavedQueryAction } from './types'; | ||
|
||
describe('selectSavedQuery()', () => { | ||
describe('Scenario 1: User selects query with enabled autorun', () => { | ||
const action = selectSavedQuery('purchases', true); | ||
const it = sagaHelper( | ||
selectSavedQueryFlow(action as SelectSavedQueryAction) | ||
); | ||
|
||
it('get list of saved queries from state', (result) => { | ||
expect(result).toEqual(select(getSavedQueries)); | ||
return savedQueries; | ||
}); | ||
|
||
it('setup visualization type', (result) => { | ||
const chartSettings = { | ||
layout: 'vertical' as Layout, | ||
}; | ||
|
||
expect(result).toEqual(put(setVisualization('bar', chartSettings, {}))); | ||
}); | ||
|
||
it('setup query settings', (result) => { | ||
const query = { | ||
analysis_type: 'count', | ||
}; | ||
|
||
expect(result).toEqual(put(setQuerySettings(query))); | ||
}); | ||
|
||
it('updates save query settings', (result) => { | ||
const savedQuery = { | ||
cached: false, | ||
displayName: 'purchases', | ||
name: 'purchases', | ||
tags: [], | ||
}; | ||
expect(result).toMatchObject(put(updateSaveQuery(savedQuery))); | ||
}); | ||
|
||
it('runs selected query', (result) => { | ||
const query = { | ||
analysis_type: 'count', | ||
}; | ||
|
||
expect(result).toEqual(put(runQuery(query))); | ||
}); | ||
}); | ||
}); |
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