forked from jeff-collins/ment.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(karma): add support for karma and a basic test
- Loading branch information
Showing
7 changed files
with
359 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.idea | ||
|
||
coverage | ||
test-reports | ||
node_modules | ||
bower_components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"asi" : false, | ||
"bitwise" : false, | ||
"boss" : true, | ||
"browser" : true, | ||
"camelcase" : false, | ||
"couch" : false, | ||
"curly" : false, | ||
"debug" : true, | ||
"devel" : true, | ||
"dojo" : false, | ||
"eqeqeq" : true, | ||
"eqnull" : true, | ||
"esnext" : false, | ||
"evil" : true, | ||
"expr" : true, | ||
"forin" : true, | ||
"funcscope" : false, | ||
"globalstrict" : true, | ||
"immed" : true, | ||
"indent" : 4, | ||
"iterator" : false, | ||
"jquery" : true, | ||
"lastsemic" : true, | ||
"latedef" : true, | ||
"laxbreak" : false, | ||
"laxcomma" : false, | ||
"loopfunc" : false, | ||
"maxcomplexity" : 10, | ||
"maxdepth" : 4, | ||
"maxerr" : 100, | ||
"maxlen" : 120, | ||
"maxstatements" : 35, | ||
"mootools" : false, | ||
"multistr" : false, | ||
"newcap" : true, | ||
"noarg" : true, | ||
"node" : true, | ||
"noempty" : true, | ||
"nomen" : false, | ||
"nonstandard" : false, | ||
"onecase" : false, | ||
"onevar" : false, | ||
"passfail" : false, | ||
"plusplus" : false, | ||
"predef" : [ | ||
"__dirname", | ||
"element", | ||
"browser", | ||
"require", | ||
"jasmine", | ||
"describe", | ||
"xdescribe", | ||
"it", | ||
"iit", | ||
"angular", | ||
"inject", | ||
"xit", | ||
"beforeEach", | ||
"afterEach", | ||
"expect", | ||
"input", | ||
"pause", | ||
"spyOn", | ||
"runs", | ||
"waits", | ||
"waitsFor", | ||
"Benchmark", | ||
"Raphael", | ||
"Backbone", | ||
"Modernizr", | ||
"Handlebars", | ||
"Ext", | ||
"_gaq", | ||
"module", | ||
"exports", | ||
"define", | ||
"$", | ||
"jQuery", | ||
"grunt", | ||
"phantom", | ||
"WebPage" | ||
], | ||
"proto" : false, | ||
"prototypejs" : false, | ||
"quotmark" : "single", | ||
"regexdash" : false, | ||
"regexp" : false, | ||
"rhino" : false, | ||
"scripturl" : false, | ||
"shadow" : false, | ||
"smarttabs" : false, | ||
"strict" : true, | ||
"sub" : false, | ||
"supernew" : false, | ||
"trailing" : true, | ||
"undef" : true, | ||
"unused" : true, | ||
"validthis" : false, | ||
"white" : false, | ||
"wsh" : false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict'; | ||
|
||
describe('mentio-menu directive', function () { | ||
var $compile, $rootScope; | ||
|
||
beforeEach(module('mentio')); | ||
|
||
beforeEach(inject(function (_$compile_, _$rootScope_) { | ||
$compile = _$compile_; | ||
$rootScope = _$rootScope_; | ||
})); | ||
|
||
it('should search on items', function () { | ||
var element, $renderScope, $scope, searchSpy, mockItems; | ||
|
||
mockItems = [ | ||
{ | ||
id: 1 | ||
}, | ||
{ | ||
id: 2 | ||
} | ||
]; | ||
|
||
$renderScope = $rootScope.$new(); | ||
|
||
$renderScope.search = function (term) { | ||
if (term === 'foo') { | ||
$renderScope.items = mockItems; | ||
} else { | ||
$renderScope.items = []; | ||
} | ||
}; | ||
|
||
searchSpy = spyOn($renderScope, 'search'); | ||
searchSpy.andCallThrough(); | ||
|
||
element = $compile('<div mentio-menu bind="content" items="items"' + | ||
'search="search(term)" select="select(item)" ng-model="menuContent">')($renderScope); | ||
|
||
$renderScope.$digest(); | ||
|
||
$scope = element.isolateScope(); | ||
|
||
// TODO: move getAtMentionInfo() into a service so it can be mocked | ||
$scope.atVar = 'foo'; | ||
expect($scope.hide).toBeTruthy(); | ||
$scope.query(); | ||
|
||
$renderScope.$digest(); | ||
|
||
expect(searchSpy).toHaveBeenCalledWith('foo'); | ||
expect($scope.items).toEqual(mockItems); | ||
expect($scope.hide).toBeFalsy(); | ||
|
||
|
||
/* | ||
* The menu should not display when the search returns no items | ||
*/ | ||
$scope.atVar = 'bar'; | ||
$scope.query(); | ||
|
||
$renderScope.$digest(); | ||
|
||
expect(searchSpy.callCount).toBe(2); | ||
expect($scope.items).toEqual([]); | ||
expect($scope.hide).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
'use strict'; | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
frameworks: ['jasmine'], | ||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'bower_components/angular/angular.js', | ||
'bower_components/angular-mocks/angular-mocks.js', | ||
'./dist/**/*.js' | ||
], | ||
|
||
// list of files to exclude | ||
exclude: [], | ||
|
||
preprocessors: { | ||
'./dist/**/!(*.spec).js': 'coverage' | ||
}, | ||
|
||
// use dots reporter, as travis terminal does not support escaping sequences | ||
// possible values: 'dots', 'progress' | ||
// CLI --reporters progress | ||
reporters: ['junit','progress','coverage','threshold'], | ||
|
||
junitReporter: { | ||
outputFile: 'test-reports/junit.xml', | ||
suite: 'ment.io' | ||
}, | ||
|
||
thresholdReporter: { | ||
statements: 0, | ||
branches: 0, | ||
functions: 0, | ||
lines: 0 | ||
}, | ||
|
||
coverageReporter: { | ||
type : 'html', | ||
dir : 'coverage/' | ||
}, | ||
|
||
// web server port | ||
// CLI --port 9876 | ||
port: 8085, | ||
|
||
// enable / disable colors in the output (reporters and logs) | ||
// CLI --colors --no-colors | ||
colors: true, | ||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
// CLI --log-level debug | ||
logLevel: config.LOG_INFO, | ||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
// CLI --auto-watch --no-auto-watch | ||
autoWatch: false, | ||
|
||
// Start these browsers, currently available: | ||
// - Chrome | ||
// - ChromeCanary | ||
// - Firefox | ||
// - Opera | ||
// - Safari (only Mac) | ||
// - PhantomJS | ||
// - IE (only Windows) | ||
// CLI --browsers Chrome,Firefox,Safari | ||
browsers: ['PhantomJS'], | ||
|
||
// If browser does not capture in given timeout [ms], kill it | ||
// CLI --capture-timeout 5000 | ||
captureTimeout: 20000, | ||
|
||
// Auto run tests on start (when browsers are captured) and exit | ||
// CLI --single-run --no-single-run | ||
singleRun: true, | ||
|
||
// report which specs are slower than 500ms | ||
// CLI --report-slower-than 500 | ||
reportSlowerThan: 500, | ||
|
||
plugins: [ | ||
'karma-jasmine', | ||
'karma-coverage', | ||
'karma-phantomjs-launcher', | ||
'karma-chrome-launcher', | ||
'karma-junit-reporter', | ||
'karma-threshold-reporter', | ||
'karma-chrome-launcher' | ||
] | ||
}); | ||
}; | ||
|
Oops, something went wrong.