Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #60 from TomSeldon/21/markdown-converter
Browse files Browse the repository at this point in the history
[tests] Add tests for markdown converter
  • Loading branch information
TomSeldon committed Oct 25, 2015
2 parents a146af7 + 1cae542 commit fc0994a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
(function() {
'use strict';

angular.module('word-to-markdown.markdown-converter', [])
angular.module('word-to-markdown.markdown-converter', [
'word-to-markdown.get-content'
])
.service('markdownConverter', MarkdownConverterService);

/**
Expand Down Expand Up @@ -43,7 +45,7 @@

/**
* @param {string} html - HTML representation of Word document text
* @returns {string} Markdown representation of HTML
* @returns {Promise.<string>} Markdown representation of HTML
*/
MarkdownConverterService.prototype.convertFromHtml = function(html) {
var deferred = this._$q.defer();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('platform service', function() {
/** @type {MarkdownConverterService} */
var markdownConverter;

beforeEach(module('word-to-markdown.markdown-converter'));

beforeEach(inject(function($injector) {
markdownConverter = $injector.get('markdownConverter');
}));

it('expose a method for converting HTML to markdown', function() {
expect(markdownConverter.convertFromHtml).toEqual(jasmine.any(Function));
});

it('should expose a method for converting the selected text to markdown', function() {
expect(markdownConverter.convertSelectedText).toEqual(jasmine.any(Function));
});

// todo: Add more meaningful tests once suitable mocks for Office and upndown are in place
});
2 changes: 1 addition & 1 deletion app/components/office/office.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
* @returns {Office|undefined} The Office JS API
*/
function officeFactory($window) {
return $window.Office;
return $window.Office || null;
}
})();
2 changes: 1 addition & 1 deletion app/components/platform/platform.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @returns {boolean} Returns true if we're running in a Microsoft Office environment
*/
PlatformService.prototype.isRunningInOffice = function() {
var hasContext = typeof this._office.context !== 'undefined';
var hasContext = this._office && typeof this._office.context !== 'undefined';

return hasContext && typeof this._office.context.document !== 'undefined';
};
Expand Down
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"devDependencies": {
"angular-mocks": "~1.4.7",
"to-markdown": "~1.3.0"
"to-markdown": "~1.3.0",
"es5-shim": "~4.1.15"
}
}
3 changes: 3 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module.exports = function(config) {
config.set({
files: [
// Vendor
'bower_components/es5-shim/es5-shim.js',
'bower_components/promise-polyfill/Promise.js',
'bower_components/jquery/jquery.js',
'node_modules/upndown/lib/upndown.bundle.js',
'bower_components/office-ui-fabric/dist/js/jquery.fabric.min.js',
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
Expand Down

0 comments on commit fc0994a

Please sign in to comment.