webogram-i2p/test/unit/controllers/ChangelogModalControlelerSpec.js
Bart 82957f1b91 Added structure to test directory, Fully tested filters.js (#1393)
* added tests for filter.js, Added structure to test-directory

In the gulpfile I changed some of the karma execution to ensure templates.js exists before the tests
Also removed some StandardJS errors from filters.js

* added tests to create at least 50% coverage for filters.js

* Added test for full coverage of filters.js

* fixed 2 side-cases

* Removed duplicate test, improved test-titles and added outcome clarification for dateOrTimeFilter

* Added test-init

While running ``gulp test`` there were a lot of warnings concerning i18n: key not found
This was because init.js was not run.
Because some parts of init.js were not relevant, I created test-init.js, only containing the part concerning localization.
Now the log is a lot cleaner when running ``gulp test``

* added 'use strict' to testing files

* changed local vars to this.

* improved clarity of mistery numbers

* improved in-test structure

* Improved shortUrl tests

* removed unnecessary code

* added cleanup to single test
2017-04-29 11:54:46 +03:00

71 lines
2.0 KiB
JavaScript

'use strict'
/* global describe, it, inject, expect, beforeEach, Config */
describe('ChangeLogModalController', function () {
var $controller, $scope, modal, modalFlag
beforeEach(module('myApp.controllers'))
beforeEach(function () {
modalFlag = false
modal = {
open: function (data) {
modalFlag = true
}
}
inject(function (_$controller_, _$rootScope_) {
$controller = _$controller_
$scope = _$rootScope_.$new()
$controller('ChangelogModalController', {
$scope: $scope,
$modal: modal
})
})
})
// define tests
it('will have standard data when no function is called', function (done) {
expect($scope.changelogHidden).toBe(false)
expect($scope.changelogShown).toBe(false)
expect($scope.currentVersion).toBe(Config.App.version)
done()
})
it('will show the changelog', function (done) {
$scope.showAllVersions()
expect($scope.changelogHidden).toBe(false)
expect($scope.changelogShown).toBe(true)
done()
})
it('will allow to show any version when "changelogShown" is true', function (done) {
$scope.changelogShown = true
expect($scope.canShowVersion(null)).toBe(true)
expect($scope.canShowVersion('0.0.1')).toBe(true)
expect($scope.canShowVersion('0.1.0')).toBe(true)
expect($scope.canShowVersion('1.0.0')).toBe(true)
done()
})
it('will allow the version to be shown when the current verion is bigger than the last function', function (done) {
expect($scope.canShowVersion('100.100.100')).toBe(true)
done()
})
it('won\'t allow the version to be shown when it is smaller than the current version', function (done) {
expect($scope.changelogHidden).toBe(false)
expect($scope.canShowVersion('0.0.0')).toBe(false)
expect($scope.changelogHidden).toBe(true)
done()
})
it('will call modal when the changeUsername function is called', function (done) {
expect(modalFlag).toBe(false)
$scope.changeUsername()
expect(modalFlag).toBe(true)
done()
})
})