Skip to content

Commit 1d98d47

Browse files
author
CloudNiner
committed
Merge branch 'feature/first-tests' into develop
2 parents d1aaf5f + 6f48c76 commit 1d98d47

14 files changed

+169
-235
lines changed

.jshintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@
5353

5454
"browser": true,
5555
"node": true,
56+
"mocha": true,
5657

5758
"globals": {
5859
"angular": false,
5960
"L": false,
60-
"$": false
61+
"$": false,
62+
"jasmine": false,
63+
"inject": false,
64+
"expect": false
6165
}
6266
}

dist/azavea-ng-leaflet.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106

107107
ctl.getMap = getMap;
108108
ctl.setMap = setMap;
109+
ctl.invalidateMapSize = invalidateMapSize;
109110
}
110111

111112
/**
@@ -124,8 +125,15 @@
124125

125126
// This helps in some situations where the map isn't initially rendered correctly due
126127
// to the container size being changed.
128+
invalidateMapSize();
129+
}
130+
131+
function invalidateMapSize() {
132+
if (!_map) {
133+
return;
134+
}
127135
$timeout(function() {
128-
map.invalidateSize();
136+
_map.invalidateSize();
129137
}, 0);
130138
}
131139
}
@@ -334,13 +342,7 @@
334342
AZLeafletData.setMap(map, attrs.id);
335343

336344
scope.$on('$destroy', onScopeDestroy);
337-
scope.$on('az.leaflet.invalidatesize', onInvalidateSize);
338-
339-
function onInvalidateSize() {
340-
$timeout(function () {
341-
map.invalidateSize();
342-
});
343-
}
345+
scope.$on('az.leaflet.invalidatesize', controller.invalidateMapSize);
344346

345347
function onScopeDestroy() {
346348
map.remove();

dist/azavea-ng-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,33 @@ var rootDirectory = path.resolve('./');
1818

1919
// Source directory for build process
2020
var sourceDirectory = path.join(rootDirectory, './src');
21+
// Test directory for test files
22+
var testDirectory = path.join(rootDirectory, './test');
2123

2224
var sourceFiles = [
2325

2426
// Make sure module files are handled first
2527
path.join(sourceDirectory, '/**/module.js'),
2628

2729
// Then add all JavaScript files
28-
path.join(sourceDirectory, '/**/*.js')
30+
path.join(sourceDirectory, '/**/*.js'),
31+
32+
];
33+
34+
var testFiles = [
35+
// All unit test files
36+
path.join(testDirectory, '/unit/**/*.spec.js'),
37+
38+
path.join(testDirectory, '/e2e/**/*.spec.js')
2939
];
3040

41+
var allFiles = sourceFiles + testFiles;
42+
3143
var lintFiles = [
3244
'gulpfile.js',
3345
// Karma configuration
34-
'karma-*.conf.js'
35-
].concat(sourceFiles);
46+
'karma.conf.js'
47+
].concat(allFiles);
3648

3749
gulp.task('build', function() {
3850
gulp.src(sourceFiles)
@@ -49,7 +61,7 @@ gulp.task('build', function() {
4961
* Process
5062
*/
5163
gulp.task('process-all', function (done) {
52-
runSequence('jshint', 'test-src', 'build', done);
64+
runSequence('jshint', 'test', 'build', done);
5365
});
5466

5567
/**
@@ -58,7 +70,7 @@ gulp.task('process-all', function (done) {
5870
gulp.task('watch', function () {
5971

6072
// Watch JavaScript files
61-
gulp.watch(sourceFiles, ['process-all']);
73+
gulp.watch(allFiles, ['process-all']);
6274
});
6375

6476
/**
@@ -75,29 +87,9 @@ gulp.task('jshint', function () {
7587
/**
7688
* Run test once and exit
7789
*/
78-
gulp.task('test-src', function (done) {
79-
karma.start({
80-
configFile: __dirname + '/karma-src.conf.js',
81-
singleRun: true
82-
}, done);
83-
});
84-
85-
/**
86-
* Run test once and exit
87-
*/
88-
gulp.task('test-dist-concatenated', function (done) {
89-
karma.start({
90-
configFile: __dirname + '/karma-dist-concatenated.conf.js',
91-
singleRun: true
92-
}, done);
93-
});
94-
95-
/**
96-
* Run test once and exit
97-
*/
98-
gulp.task('test-dist-minified', function (done) {
90+
gulp.task('test', function (done) {
9991
karma.start({
100-
configFile: __dirname + '/karma-dist-minified.conf.js',
92+
configFile: __dirname + '/karma.conf.js',
10193
singleRun: true
10294
}, done);
10395
});

karma-dist-concatenated.conf.js

Lines changed: 0 additions & 77 deletions
This file was deleted.

karma-dist-minified.conf.js

Lines changed: 0 additions & 77 deletions
This file was deleted.

karma-src.conf.js renamed to karma.conf.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@ module.exports = function(config) {
1010

1111
// frameworks to use
1212
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13-
frameworks: ['mocha', 'chai-jquery', 'jquery-1.8.3', 'sinon-chai'],
13+
frameworks: ['jasmine', 'jquery-1.8.3'],
1414

1515
plugins: [
16-
'karma-mocha',
17-
'karma-chai',
18-
'karma-sinon-chai',
1916
'karma-chrome-launcher',
2017
'karma-phantomjs-launcher',
2118
'karma-jquery',
22-
'karma-chai-jquery',
19+
'karma-jasmine',
2320
'karma-spec-reporter'
2421
],
2522

2623
// list of files / patterns to load in the browser
2724
files: [
2825
'bower/angular/angular.js',
2926
'bower/angular-mocks/angular-mocks.js',
27+
'bower/leaflet/dist/leaflet-src.js',
3028
'src/**/module.js',
3129
'src/**/*.js',
3230
'test/unit/**/*.js'

package.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,15 @@
2828
"gulp-plumber": "^0.6.6",
2929
"gulp-rename": "^1.2.0",
3030
"gulp-uglify": "^0.3.1",
31+
"jasmine-core": "^2.4.1",
3132
"jshint-stylish": "^0.4.0",
3233
"karma": "^0.12.22",
33-
"karma-chai": "^0.1.0",
34-
"karma-chai-jquery": "^1.0.0",
3534
"karma-chrome-launcher": "^0.1.4",
36-
"karma-jasmine": "^0.1.5",
35+
"karma-jasmine": "^0.3.6",
3736
"karma-jquery": "^0.1.0",
38-
"karma-mocha": "^0.1.8",
3937
"karma-phantomjs-launcher": "^0.1.4",
40-
"karma-sinon-chai": "^0.2.0",
4138
"karma-spec-reporter": "^0.0.18",
42-
"mocha": "^1.21.4",
43-
"run-sequence": "^1.0.2",
44-
"sinon": "^1.10.3",
45-
"sinon-chai": "^2.5.0"
39+
"run-sequence": "^1.0.2"
4640
},
4741
"engines": {
4842
"node": ">=0.8.0"

src/az.leaflet/leaflet-controller.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
ctl.getMap = getMap;
1515
ctl.setMap = setMap;
16+
ctl.invalidateMapSize = invalidateMapSize;
1617
}
1718

1819
/**
@@ -31,8 +32,15 @@
3132

3233
// This helps in some situations where the map isn't initially rendered correctly due
3334
// to the container size being changed.
35+
invalidateMapSize();
36+
}
37+
38+
function invalidateMapSize() {
39+
if (!_map) {
40+
return;
41+
}
3442
$timeout(function() {
35-
map.invalidateSize();
43+
_map.invalidateSize();
3644
}, 0);
3745
}
3846
}

src/az.leaflet/leaflet.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,7 @@
3636
AZLeafletData.setMap(map, attrs.id);
3737

3838
scope.$on('$destroy', onScopeDestroy);
39-
scope.$on('az.leaflet.invalidatesize', onInvalidateSize);
40-
41-
function onInvalidateSize() {
42-
$timeout(function () {
43-
map.invalidateSize();
44-
});
45-
}
39+
scope.$on('az.leaflet.invalidatesize', controller.invalidateMapSize);
4640

4741
function onScopeDestroy() {
4842
map.remove();

0 commit comments

Comments
 (0)