vendor script view specs

pull/12704/head
Carlos Matallín 7 years ago
parent 17b9680d23
commit b985157c6b

@ -37,5 +37,5 @@
email: "<%= userEmail %>"
};
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/<%= intercom_app_id %>';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/<%= intercomAppId %>';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
<% } %>

@ -0,0 +1,72 @@
var cdb = require('cartodb.js-v3');
var VendorScriptsView = require('../../../../javascripts/cartodb/common/vendor_scripts_view');
var CONFIG = {
trackjs_customer: 'trackjs_customer',
trackjs_enabled: true,
trackjs_app_key: 'trackjs_app_key',
google_analytics_ua: 'UA-20934186-25',
google_analytics_domain: 'carto.com',
hubspot_enabled: true,
hubspot_token: 'yourtoken',
hubspot_ids: '{}',
intercom_app_id: 'intercom_app_id'
};
describe('common/vendor_scripts_view', function () {
beforeEach(function () {
this.user = new cdb.admin.User({
username: 'pepe',
base_url: 'http://pepe.carto.com',
email: 'e00000002@d00000002.com',
account_type: 'FREE'
});
spyOn(this.user, 'featureEnabled').and.returnValue(true);
this.view = new VendorScriptsView({
config: CONFIG,
assetsVersion: '1.0.0',
user: this.user
});
});
it('should render given template with template data', function () {
spyOn(this.view, 'template');
this.view.render();
expect(this.view.template).toHaveBeenCalledWith({
trackjsCustomer: 'trackjs_customer',
trackjsEnabled: true,
trackjsAppKey: 'trackjs_app_key',
assetsVersion: '1.0.0',
userName: 'pepe',
ua: 'UA-20934186-25',
domain: 'carto.com',
memberType: 'FREE',
hubspotEnabled: true,
hubspotToken: 'yourtoken',
hubspotIds: '{}',
intercomEnabled: true,
intercomAppId: 'intercom_app_id',
userEmail: 'e00000002@d00000002.com'
});
});
it("should inject the rendered results into the view's element", function () {
spyOn(this.view, 'template').and.returnValue('<div>foo bar!</div>');
spyOn(this.view.$el, 'html');
this.view.render();
expect(this.view.$el.html).toHaveBeenCalledWith('<div>foo bar!</div>');
});
it('should have no leaks', function () {
expect(this.view).toHaveNoLeaks();
});
afterEach(function () {
this.view.clean();
});
});

@ -14,7 +14,6 @@ module.exports = {
// enables watchify when grunt is run with a watch task
// must be evaluated lazily (using template var) to allow override by setConfig task.
// watch: '<%= env.browserify_watch %>',
watch: '<%= env.browserify_watch %>',
browserifyOptions: {

@ -32,7 +32,7 @@ module.exports = {
headless: true,
timeout: 20000,
keepRunner: true,
outfile: '_SpecRunner-affected.html',
outfile: '_SpecRunner.html',
host: 'http://localhost:8088',
summary: true,
display: 'short',

@ -82,6 +82,8 @@ exports.task = function () {
},
js_affected_editor: {
files: [
'lib/assets/javascripts/cartodb/**/*',
'!lib/assets/core/javascripts/cartodb/organization/**/*',
'lib/assets/test/spec/cartodb/**/*'
],
tasks: [

Loading…
Cancel
Save