Commit 9a80b6ac authored by Robert Knight's avatar Robert Knight

Convert markdown-test mocking to babel-plugin-mockable-imports

parent a82d1941
'use strict';
const angular = require('angular');
const proxyquire = require('proxyquire');
const util = require('../../directive/test/util');
const noCallThru = require('../../../shared/test/util').noCallThru;
const markdown = require('../markdown');
describe('markdown', function() {
function isHidden(element) {
......@@ -40,46 +39,39 @@ describe('markdown', function() {
}
before(function() {
angular.module('app').component(
'markdown',
proxyquire(
'../markdown',
noCallThru({
angular: angular,
katex: {
renderToString: function(input) {
return 'math:' + input.replace(/$$/g, '');
},
},
angular.module('app', []).component('markdown', markdown);
});
beforeEach(function() {
angular.mock.module('app');
markdown.$imports.$mock({
'lodash.debounce': function(fn) {
// Make input change debouncing synchronous in tests
return function() {
fn();
};
},
'../render-markdown': noCallThru(function(markdown) {
'../render-markdown': markdown => {
return 'rendered:' + markdown;
}),
},
'../markdown-commands': {
convertSelectionToLink: mockFormattingCommand,
toggleBlockStyle: mockFormattingCommand,
toggleSpanStyle: mockFormattingCommand,
LinkType: require('../../markdown-commands').LinkType,
},
'../media-embedder': noCallThru({
'../media-embedder': {
replaceLinksWithEmbeds: function(element) {
// Tag the element as having been processed
element.dataset.replacedLinksWithEmbeds = 'yes';
},
}),
})
)
);
},
});
});
beforeEach(function() {
angular.mock.module('app');
afterEach(() => {
markdown.$imports.$restore();
});
describe('read only state', function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment