Skip to content
This repository has been archived by the owner on May 5, 2018. It is now read-only.

Commit

Permalink
[FIX] Unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Feb 10, 2013
1 parent 0414834 commit 147089d
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions modules/directives/codemirror/test/codemirrorSpec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/*global beforeEach, afterEach, describe, it, inject, expect, module, spyOn, CodeMirror, angular, $*/
/**
* TODO Test all the CodeMirror events : cursorActivity viewportChange gutterClick focus blur scroll update.
* with <textarea ui-codemirror="{onChange: doChange ,onCursorActivity: doSomething}" ng-model="foo">
*
*/

describe('uiCodemirror', function () {
'use strict';

// declare these up here to be global to all tests
var $rootScope, $compile, $timeout, uiConfig = angular.module('ui.config');

beforeEach(module('ui.directives'));
beforeEach(function () {
uiConfig.value('ui.config', {codemirror: {bar: 'baz'}});
});

// inject in angular constructs. Injector knows about leading/trailing underscores and does the right thing
// otherwise, you would need to inject these into each test
Expand All @@ -21,7 +20,7 @@ describe('uiCodemirror', function () {
}));

afterEach(function () {
angular.module('ui.config').value('ui.config', {}); // cleanup
uiConfig.value('ui.config', {}); // cleanup
});

describe('compiling this directive', function () {
Expand Down Expand Up @@ -56,20 +55,28 @@ describe('uiCodemirror', function () {
expect($rootScope.$watch).toHaveBeenCalled();
});

// Sorry I'm not enough familiar Jasmine to fix this...
/*
it('should include the passed options', function () {
spyOn(CodeMirror, 'fromTextArea');
$compile('<textarea ui-codemirror="{foo: \'bar\'}" ng-model="foo"></textarea>')($rootScope);
expect(CodeMirror.fromTextArea.mostRecentCall.args[1].foo).toEqual('bar');
var codemirror, options,
fromTextArea = CodeMirror.fromTextArea;
spyOn(CodeMirror, 'fromTextArea').andCallFake(function () {
codemirror = fromTextArea.apply(this, arguments);
return codemirror;
});
$compile('<textarea ui-codemirror="{fooo: \'baar\'}" ng-model="foo"></textarea>')($rootScope);
$timeout.flush();
expect(CodeMirror.fromTextArea.mostRecentCall.args[1].fooo).toEqual("baar");
});

it('should include the default options', function () {
spyOn(CodeMirror, 'fromTextArea');
$compile('<textarea ui-codemirror ng-model="foo"></textarea>')($rootScope);
it('should include the default options', function () {var codemirror, options,
fromTextArea = CodeMirror.fromTextArea;
spyOn(CodeMirror, 'fromTextArea').andCallFake(function () {
codemirror = fromTextArea.apply(this, arguments);
return codemirror;
});
$compile('<textarea ui-codemirror ng-model="foo"></textarea>')($rootScope);
$timeout.flush();
expect(CodeMirror.fromTextArea.mostRecentCall.args[1].bar).toEqual('baz');
});
*/
});

describe('when the model changes', function () {
Expand Down

0 comments on commit 147089d

Please sign in to comment.