This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add karma, Jasmine, deps and karma.conf.js. Fixes #1291 * Improved service worker code * npm start script executes gulp watch task. * Written a gulp task to compile templates AOT. Get rid of loading deps in unit tests and a preprocessor. * PhantomJS package is deprecated. Use phantomjs-prebuilt instead. * Adjust `npm run test`.
- Loading branch information
Showing
12 changed files
with
478 additions
and
2 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
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,111 @@ | ||
// Karma configuration | ||
// Generated on Thu Dec 15 2016 21:12:39 GMT+0100 (CET) | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
|
||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: 'app', | ||
|
||
|
||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['jasmine'], | ||
|
||
|
||
// list of files / patterns to load in the browser | ||
// Load files to access global variables | ||
files: [ | ||
{pattern: 'js/lib/polyfill.js', watched: false}, | ||
{pattern: 'vendor/jquery/jquery.min.js', watched: false}, | ||
{pattern: 'js/lib/config.js', watched: false}, | ||
{pattern: 'vendor/jquery.nanoscroller/nanoscroller.js', watched: false}, | ||
{pattern: 'vendor/angular/angular.js', watched: false}, | ||
{pattern: 'vendor/angular/angular-mocks.js', watched: false}, | ||
{pattern: 'vendor/angular/angular-route.js', watched: false}, | ||
{pattern: 'vendor/angular/angular-animate.js', watched: false}, | ||
{pattern: 'vendor/angular/angular-sanitize.js', watched: false}, | ||
{pattern: 'vendor/angular/angular-touch.js', watched: false}, | ||
{pattern: 'vendor/ui-bootstrap/ui-bootstrap-custom-tpls-0.12.0.js', watched: false}, | ||
{pattern: 'vendor/angular-media-player/angular-media-player.js', watched: false}, | ||
{pattern: 'vendor/jsbn/jsbn_combined.js', watched: false}, | ||
{pattern: 'vendor/cryptoJS/crypto.js', watched: false}, | ||
{pattern: 'vendor/rusha/rusha.js', watched: false}, | ||
{pattern: 'vendor/zlib/gunzip.min.js', watched: false}, | ||
{pattern: 'vendor/closure/long.js', watched: false}, | ||
{pattern: 'vendor/leemon_bigint/bigint.js', watched: false}, | ||
{pattern: 'vendor/libwebpjs/libwebp-0.2.0.js', watched: false}, | ||
{pattern: 'vendor/angularjs-toaster/toaster.js', watched: false}, | ||
{pattern: 'vendor/clipboard/clipboard.js', watched: false}, | ||
{pattern: 'js/lib/utils.js', watched: false}, | ||
{pattern: 'js/lib/bin_utils.js', watched: false}, | ||
{pattern: 'js/lib/tl_utils.js', watched: false}, | ||
{pattern: 'js/lib/ng_utils.js', watched: false}, | ||
{pattern: 'js/lib/i18n.js', watched: false}, | ||
{pattern: 'js/lib/mtproto.js', watched: false}, | ||
{pattern: 'js/lib/mtproto_wrapper.js', watched: false}, | ||
'js/templates.js', // Generated by `gulp templates` | ||
'js/services.js', | ||
'js/filters.js', | ||
'js/controllers.js', | ||
'js/directives.js', | ||
'../test/unit/*.js' | ||
], | ||
|
||
|
||
// list of files to exclude | ||
exclude: [ | ||
'js/background.js' | ||
], | ||
|
||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'js/*.js': ['coverage'], | ||
}, | ||
|
||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress', 'coverage'], | ||
|
||
|
||
coverageReporter: { | ||
type: 'text', | ||
dir: 'coverage/' | ||
}, | ||
|
||
|
||
// web server port | ||
port: 9876, | ||
|
||
|
||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
|
||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
|
||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: true, | ||
|
||
|
||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['PhantomJS'], | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: false, | ||
|
||
// Concurrency level | ||
// how many browser should be started simultaneous | ||
concurrency: Infinity, | ||
}) | ||
} |
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,50 @@ | ||
describe('AppLangSelectController', function () { | ||
var $controller, $scope; | ||
|
||
beforeEach(module('ui.bootstrap')); | ||
beforeEach(module('myApp.services')); | ||
beforeEach(module('myApp.controllers')); | ||
|
||
beforeEach(function () { | ||
inject(function (_$controller_, _$rootScope_, _, Storage, ErrorService, AppRuntimeManager) { | ||
$controller = _$controller_; | ||
$scope = _$rootScope_.$new() | ||
$controller('AppLangSelectController', { | ||
$scope: $scope, | ||
_: _, | ||
Storage: Storage, | ||
ErrorService: ErrorService, | ||
AppRuntimeManager: AppRuntimeManager | ||
}); | ||
}); | ||
}); | ||
|
||
it('holds the supportedLocales', function () { | ||
expect($scope.supportedLocales).toBeDefined(); | ||
}); | ||
|
||
it('holds langNames', function () { | ||
expect($scope.langNames).toBeDefined(); | ||
}); | ||
|
||
it('holds the current locale', function () { | ||
expect($scope.curLocale).toBeDefined(); | ||
}); | ||
|
||
it('has a locale form', function () { | ||
expect($scope.form).toBeDefined(); | ||
expect($scope.form.locale).toBeDefined(); | ||
}); | ||
|
||
it('allows to select a locale', function () { | ||
expect($scope.localeSelect).toBeDefined(); | ||
}); | ||
|
||
describe('when the user switches the locale', function () { | ||
describe('and confirms the dialogue', function () { | ||
xit('reloads the app', function (done) { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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,50 @@ | ||
describe('AppWelcomeController', function () { | ||
var $controller, $rootScope, $scope, $location, MtApiManager, ErrorService, | ||
ChangelogNotifyService, LayoutSwitchService; | ||
|
||
beforeEach(module('myApp.controllers')); | ||
|
||
beforeEach(function () { | ||
ChangelogNotifyService = { | ||
checkUpdate: function () {} | ||
}; | ||
|
||
LayoutSwitchService = { | ||
start: function () {} | ||
}; | ||
|
||
MtpApiManager = { | ||
getUserID: function () { | ||
return { | ||
then: function () {} | ||
}; | ||
} | ||
}; | ||
|
||
module(function ($provide) { | ||
$provide.value('MtpApiManager', MtpApiManager); | ||
}); | ||
|
||
inject(function (_$controller_, _$rootScope_, _$location_) { | ||
$controller = _$controller_; | ||
$rootScope = _$rootScope_; | ||
$location = _$location_; | ||
|
||
$scope = $rootScope.$new(); | ||
$controller('AppWelcomeController', { | ||
$scope: $scope, | ||
$location: $location, | ||
MtpApiManager: MtpApiManager, | ||
ErrorService: ErrorService, | ||
ChangelogNotifyService: ChangelogNotifyService, | ||
LayoutSwitchService: LayoutSwitchService | ||
}); | ||
}); | ||
}); | ||
|
||
// https://stackoverflow.com/a/36460924 | ||
it('executes a dummy spec', function (done) { | ||
expect(true).toBe(true); | ||
done(); | ||
}); | ||
}); |
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,56 @@ | ||
describe('PhonebookContactsService', function () { | ||
var PhonebookContactsService; | ||
|
||
beforeEach(module('ui.bootstrap')); | ||
beforeEach(module('myApp.services')); | ||
|
||
beforeEach(inject(function (_PhonebookContactsService_) { | ||
PhonebookContactsService = _PhonebookContactsService_; | ||
})); | ||
|
||
describe('Public API:', function () { | ||
it('checks availability', function () { | ||
expect(PhonebookContactsService.isAvailable).toBeDefined(); | ||
}); | ||
|
||
it('open the phonebook for import', function () { | ||
expect(PhonebookContactsService.openPhonebookImport).toBeDefined(); | ||
}); | ||
|
||
it('get phonebook contacts', function () { | ||
expect(PhonebookContactsService.getPhonebookContacts).toBeDefined(); | ||
}); | ||
|
||
describe('usage', function () { | ||
describe('of isAvailable()', function () { | ||
it('returns false in most cases', function (done) { | ||
expect(PhonebookContactsService.isAvailable()).toBe(false); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('of openPhonebookImport()', function () { | ||
beforeEach(function() { | ||
$modal = { | ||
open: jasmine.createSpy('open') | ||
}; | ||
}); | ||
|
||
xit('opens a modal', function () { | ||
PhonebookContactsService.openPhonebookImport(); | ||
expect($modal.open).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('of getPhonebookContacts()', function () { | ||
xit('will get rejected in most cases', function (done) { | ||
promise = PhonebookContactsService.getPhonebookContacts(); | ||
promise.finally(function () { | ||
expect(promise.isFullfilled()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,31 @@ | ||
describe('chatTitle filter', function () { | ||
var $filter, _, chatTitleFilter; | ||
|
||
beforeEach(module('myApp.filters')); | ||
|
||
beforeEach(inject(function (_$filter_, ___) { | ||
$filter = _$filter_; | ||
_ = ___; | ||
})); | ||
|
||
beforeEach(function () { | ||
chatTitleFilter = $filter('chatTitle'); | ||
}); | ||
|
||
it('displays chat title deleted', function () { | ||
var expected = _('chat_title_deleted'); | ||
var actual = chatTitleFilter(null); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('displays the chat title', function () { | ||
var chat = { | ||
title: 'Telegraph is hot!' | ||
}; | ||
var expected = chat.title; | ||
var actual = chatTitleFilter(chat); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
}); |
Oops, something went wrong.