Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(() => {
client = new KeenAnalysis(TestHelpers.createClient());
// spyDispatch.mockClear();
});
describe('actions/ExplorerActions', () => {
const analysisClient = new KeenAnalysis(TestHelpers.createClient());
const mockDispatch = jest.fn();
let spyGet;
let client;
let spyRunQuery;
beforeAll(() => {
XHRmock.setup();
});
afterAll(() => {
spyDispatch.mockRestore();
XHRmock.teardown();
});
beforeEach(() => {
client = new KeenAnalysis(TestHelpers.createClient());
beforeEach(() => {
config = {
masterKey: 'fakeKey',
baseUrl: 'https://test-bookmarks-keen.io/projects/123/queries/saved',
client: new KeenAnalysis(KeenHelpers.createClient())
};
KeenSavedQueriesObj = new KeenSavedQueries(config);
bookmarkObj = {
id: 'some-name-original',
query_name: 'some-name',
query: {
analysis_type: 'count',
event_collection: 'activities',
},
metadata: {
visualization: { chart_type: 'metric' },
display_name: 'some name',
}
};
});
beforeEach(() => {
explorer = TestHelpers.createExplorerModel();
client = new KeenAnalysis(TestHelpers.createClient());
});
beforeEach(() => {
ExplorerStore.clearAll();
ExplorerActions.create({ id: '1', query_name: 'A persisted query', metadata: { display_name: 'some name' } });
ExplorerActions.setActive('1');
project = TestHelpers.createProject();
project.client = client = new KeenAnalysis(TestHelpers.createClient());
project.client.resources({
'events': '{protocol}://{host}/3.0/projects/{projectId}/events'
});
config = { persistence: null };
explorer = ExplorerStore.get('1');
component = TestUtils.renderIntoDocument();
});
beforeEach(() => {
client = new KeenAnalysis(TestHelpers.createClient());
model = TestHelpers.createExplorerModel();
model.id = 10;
project = TestHelpers.createProject();
chartOptionsStub = jest.spyOn(ChartTypeUtils, 'getChartTypeOptions').mockImplementation(()=>{}).mockReturnValue([]);
exportToCsvStub = jest.spyOn(DataUtils, 'exportToCsv').mockImplementation(()=>{}).mockReturnValue([]);
renderComponent = function(props) {
const defaults = {
client,
model,
project,
persistence: null,
appState: AppStateStore.getState()
};
const propsExt = _.assign({}, defaults, props);
createProject: () => {
const schema = buildProjectSchema();
return {
client: new KeenAnalysis({
projectId: 'projectId',
protocol: 'https',
host: 'api.keen.io',
masterKey: 'masterKey',
apiVersion: '3.0'
}),
loading: false,
eventCollections: FormatUtils.sortItems(_.map(schema, 'name')),
schema: schema
};
},
async initialize() {
await this._web3Service.init();
this.networkId = this._web3Service.network.id;
this.analysisClient = new KeenAnalysis({
projectId: this.projectId,
readKey: this.readKey
});
this.trackingClient = new KeenTracking({
projectId: this.projectId,
writeKey: this.writeKey
});
this.sendPageView();
this._pollActiveTimeNodesCount();
}
constructor(props) {
const { keenAnalysis, keenTracking } = props;
client = keenAnalysis.instance || new KeenAnalysis(keenAnalysis.config);
if (keenTracking) {
keenTrackingClient = keenTracking.instance || new KeenTracking(keenTracking.config);
}
ReactDOM.render(
,
document.querySelector(props.container),
);
async _getActiveTimeNodesHistory() {
await this.initialized;
if (!this.isBlacklisted) {
const count = new KeenAnalysis.Query('count_unique', {
event_collection: COLLECTIONS.TIMENODES,
target_property: 'nodeAddress',
timeframe: {
start: moment()
.subtract(24, 'hours')
.toISOString(),
end: moment().toISOString()
},
interval: 'hourly',
group_by: 'nodeAddress',
filters: [
{
property_name: 'networkId',
operator: 'eq',
property_value: this.timeNodeSpecificProviderNetId
},