14313-map-button-tests
jesusbotella 6 years ago
parent d222c830db
commit b7d6958fb9

@ -8,6 +8,11 @@ module.exports = {
roots: [
`<rootDir>/${testPath}/unit/specs`
],
moduleDirectories: [
'node_modules',
'vendor/assets/javascripts/',
'lib/assets/javascripts/vendor'
],
moduleFileExtensions: [
'js',
'json',
@ -21,6 +26,13 @@ module.exports = {
'^mousewheel$': `<rootDir>/node_modules/internal-carto.js/vendor/mousewheel`,
'^mwheelIntent$': `<rootDir>/node_modules/internal-carto.js/vendor/mwheelIntent`,
'^html-css-sanitizer$': `<rootDir>/node_modules/internal-carto.js/vendor/html-css-sanitizer-bundle`,
'^tipsy$': `<rootDir>/vendor/assets/javascripts/jquery.tipsy.js`,
'^tagit$': `<rootDir>/vendor/assets/javascripts/tag-it.js`,
// '^markdown$': `<rootDir>/vendor/assets/javascripts/markdown.js`,
// '^dragster$': `<rootDir>/vendor/assets/javascripts/dragster.js`,
// '^dropzone$': `<rootDir>/vendor/assets/javascripts/dropzone.js`,
'^jquery-ui$': `<rootDir>/lib/assets/javascripts/vendor/jquery-ui.js`,
'^backbone-forms$': `<rootDir>/node_modules/backbone-forms/distribution/backbone-forms.js`,
'^cdb$': `<rootDir>/node_modules/internal-carto.js/src/cdb`,
'^cdb.log$': `<rootDir>/node_modules/internal-carto.js/src/cdb.log`,
'^cdb.core.Profiler$': `<rootDir>/node_modules/internal-carto.js/src/core/profiler`,
@ -36,7 +48,6 @@ module.exports = {
transformIgnorePatterns: [
'node_modules/(?!(internal-carto.js)/)'
],
silent: true,
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
setupFiles: [`<rootDir>/${testPath}/unit/setup`],
coverageDirectory: `<rootDir>/${testPath}/coverage`,

@ -4,3 +4,12 @@ Vue.config.productionTip = false;
// Make jQuery global without DefinePlugin
window.jQuery = require('jquery');
var Polyglot = require('node-polyglot');
var polyglot = new Polyglot({
locale: 'en', // Needed for pluralize behaviour
phrases: {}
});
window._t = polyglot.t.bind(polyglot);

@ -0,0 +1,28 @@
import { shallowMount } from '@vue/test-utils';
import CreateButton from 'new-dashboard/components/CreateButton';
let createButton, showSpy;
describe('CreateButton.vue', () => {
beforeEach(() => {
showSpy = jest.fn();
createButton = shallowMount(CreateButton, {
slots: {
default: 'New map'
},
mocks: {
$modal: { show: showSpy }
}
});
});
it('should render correct contents', () => {
expect(createButton).toMatchSnapshot();
});
it('should open CreateDialog when clicked', () => {
createButton.vm.openCreateModal();
expect(showSpy).toHaveBeenCalledWith({});
});
});
Loading…
Cancel
Save