Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix: do not append SHAs in debug mode

  • Loading branch information...
commit 1a023c59b7c7229c1357a070d354911cc71e238a 1 parent 07554a3
@vojtajina vojtajina authored
Showing with 23 additions and 11 deletions.
  1. +7 −3 src/adapter.js
  2. +3 −3 src/adapter.wrapper
  3. +13 −5 test/adapter.spec.js
View
10 src/adapter.js
@@ -22,12 +22,16 @@ var normalizePath = function(path) {
return normalized.join('/');
};
-var createPatchedLoad = function(files, originalLoadFn) {
- return function (context, moduleName, url) {
+var createPatchedLoad = function(files, originalLoadFn, locationPathname) {
+ var IS_DEBUG = /debug\.html$/.test(locationPathname);
+
+ return function(context, moduleName, url) {
url = normalizePath(url);
if (files.hasOwnProperty(url)) {
- url = url + '?' + files[url];
+ if (!IS_DEBUG) {
+ url = url + '?' + files[url];
+ }
} else {
console.error('There is no timestamp for ' + url + '!');
}
View
6 src/adapter.wrapper
@@ -1,4 +1,4 @@
-(function(karma, requirejs) {
+(function(karma, requirejs, locationPathname) {
%CONTENT%
@@ -6,6 +6,6 @@
karma.loaded = function() {};
// patch require.js
-requirejs.load = createPatchedLoad(karma.files, requirejs.load);
+requirejs.load = createPatchedLoad(karma.files, requirejs.load, locationPathname);
-})(window.__karma__, window.requirejs);
+})(window.__karma__, window.requirejs, window.location.pathname);
View
18 test/adapter.spec.js
@@ -1,13 +1,12 @@
describe('adapter requirejs', function() {
var load, originalLoadSpy;
+ var files = {
+ '/base/some/file.js': '12345'
+ };
beforeEach(function() {
- var files = {
- '/base/some/file.js': '12345'
- };
-
originalLoadSpy = jasmine.createSpy('requirejs.load');
- load = createPatchedLoad(files, originalLoadSpy);
+ load = createPatchedLoad(files, originalLoadSpy, '/');
});
@@ -27,6 +26,15 @@ describe('adapter requirejs', function() {
});
+ it('should not append timestamp when running in debug mode', function() {
+ load = createPatchedLoad(files, originalLoadSpy, '/debug.html');
+ load(null, null, '/base/some/file.js');
+
+ expect(originalLoadSpy).toHaveBeenCalled();
+ expect(originalLoadSpy.argsForCall[0][2]).toBe('/base/some/file.js');
+ });
+
+
describe('normalizePath', function() {
it('should normalize . and .. in the path', function() {
Please sign in to comment.
Something went wrong with that request. Please try again.