"use strict";

var _tape = _interopRequireDefault(require("tape"));

var _reduxBundler = require("redux-bundler");

var _referredBy = require("./referred-by");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/* eslint-disable no-undef */
const getStore = queryObj => {
  global.document = {
    cookie: ''
  };
  global.location = {
    hostname: 'xchart.com'
  };
  const store = (0, _reduxBundler.composeBundlesRaw)(_referredBy.referredByBundle, {
    name: 'stubs',
    selectQueryObject: () => queryObj || {}
  })();
  return store;
};

(0, _tape.default)('referredByBundle', async t => {
  t.equal(getStore().selectReferredBy(), null, 'should be null');
  t.deepEqual(getStore({
    somethingElse: 'yeah',
    ref_id: 'blah'
  }).reactStoreReferredBy(), {
    actionCreator: 'doUpdateQuery',
    args: [{
      somethingElse: 'yeah'
    }, {
      maintainScrollPosition: true,
      replace: true
    }]
  });
  t.end();
});