Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Stubsfields out dropPellet
var SignupLoginTracking = importPathFromDirWithMock('/Users/amiskiewicz/airlab-shared/repos/airbnb/spec/javascripts/signup_login_dls/actions', '../../../../app/assets/javascripts/signup_login_dls/SignupLoginTracking', {
'../dropPellet': function () {
function dropPellet() {
return require('../../stubs/dropPellet');
}
return dropPellet;
}()
});
var _chai = require('chai');
var _airbnbTracking = require('airbnb-tracking');
var _airbnbTracking2 = _interopRequireDefault(_airbnbTracking);
var _reduxThunk = require('redux-thunk');
import { expect } from 'chai';
import Tracking from 'airbnb-tracking';
import thunk from 'redux-thunk';
import sinon from 'sinon-sandbox';
import wrap from 'mocha-wrap';
import matchMedia from 'airbnb-o2/modules/matchMedia';
import AirDog from ':airdog';
import dropPellet from '../../stubs/dropPellet';
import Airbnb from '../../stubs/airbnb';
import mockHomePDPState from '../../mocks/HomePDPInitialStoreStateMock';
import { mockStore } from '../constructMockData';
// Stubsfields out dropPellet
const SignupLoginTracking = importWithMock(
'../../../../app/assets/javascripts/signup_login_dls/SignupLoginTracking',
{
'../dropPellet': () => require('../../stubs/dropPellet'),
},
);
import * as sharedActionCreators from '../../../../app/assets/javascripts/signup_login_dls/actions/sharedActionCreators';
import * as actionCreators from '../../../../app/assets/javascripts/signup_login_dls/actions/actionCreators';
import * as actionTypes from '../../../../app/assets/javascripts/signup_login_dls/actions/actionTypes';
import * as constants from '../../../../app/assets/javascripts/signup_login_dls/constants';
import { listingIdSelector } from '../../../../app/assets/javascripts/p3/selectors/listingSelectors';
import { checkInSelector, checkOutSelector } from '../../../../app/assets/javascripts/p3/selectors/bookItSelectors';
const storeWithTripDetails = mockStore({
...mockHomePDPState(),
signup: { form: { currentValues: { } } },
login: {
form_urls: { authenticate_form_url: 'fake' },
form: { currentValues: { rememberMe: true, email: 'email', password: 'foo' } },
},
});
...
import { expect } from 'chai';
import Tracking from 'airbnb-tracking';
import thunk from 'redux-thunk';
import sinon from 'sinon-sandbox';
import wrap from 'mocha-wrap';
import matchMedia from 'airbnb-o2/modules/matchMedia';
import AirDog from ':airdog';
import dropPellet from '../../stubs/dropPellet';
import Airbnb from '../../stubs/airbnb';
import mockHomePDPState from '../../mocks/HomePDPInitialStoreStateMock';
import { mockStore } from '../constructMockData';
// Stubsfields out dropPellet
const SignupLoginTracking = importWithMock(
'../../../../app/assets/javascripts/signup_login_dls/SignupLoginTracking',
{
'../dropPellet': dropPellet,
},
);
import * as sharedActionCreators from '../../../../app/assets/javascripts/signup_login_dls/actions/sharedActionCreators';
import * as actionCreators from '../../../../app/assets/javascripts/signup_login_dls/actions/actionCreators';
import * as actionTypes from '../../../../app/assets/javascripts/signup_login_dls/actions/actionTypes';
import * as constants from '../../../../app/assets/javascripts/signup_login_dls/constants';
import { listingIdSelector } from '../../../../app/assets/javascripts/p3/selectors/listingSelectors';
import { checkInSelector, checkOutSelector } from '../../../../app/assets/javascripts/p3/selectors/bookItSelectors';
const storeWithTripDetails = mockStore({
...mockHomePDPState(),
signup: { form: { currentValues: { } } },
login: {
form_urls: { authenticate_form_url: 'fake' },
form: { currentValues: { rememberMe: true, email: 'email', password: 'foo' } },
},
});
...
@skevy

This comment has been minimized.

Copy link
Owner Author

@skevy skevy commented May 29, 2018

The problem:

../../../../app/assets/javascripts/signup_login_dls/actions/actionCreators imports SignupLoginTracking (the module mocked with importWithMock), and because importWithMock is not hoisted, it's not actually mocking the module because it was already imported transitively.

A solution:

See actionCreators_spec-solution.js and the transformed version actionCreators_spec-solution-transformed.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment