Skip to content

Commit ded9c93

Browse files
author
Dan Shahin
committed
make it injectable
1 parent d5c8d87 commit ded9c93

File tree

7 files changed

+23
-155
lines changed

7 files changed

+23
-155
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

dist/jsr-mocks-jquery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
};
99

1010
if (!window.Visualforce){
11-
var $mocks = window.$SPA.mocks || {};
11+
var $mocks = window.configSettings.mocks || {};
1212
window.Visualforce = {
1313
//Visualforce.remoting.Manager.invokeAction
1414
remoting :{
@@ -65,4 +65,4 @@
6565
return deferred.promise();
6666
};
6767

68-
}(jQuery));
68+
}(jQuery));

dist/jsr-mocks.angular.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
jsr.$inject = ["jsrMocks", "$q", "$rootScope"];
34
Object.defineProperty(exports, "__esModule", {
45
value: true
56
});
@@ -23,6 +24,8 @@ var genericMock = {
2324
};
2425

2526
function jsrMocks() {
27+
"ngInject";
28+
2629
var $mocks;
2730
var $mockServer;
2831
return {
@@ -31,8 +34,8 @@ function jsrMocks() {
3134
$mockServer = mockServer;
3235
},
3336

34-
$get: function $get($log, $http, $window, $timeout) {
35-
'ngInject';
37+
$get: ["$timeout", function $get($timeout) {
38+
"ngInject";
3639

3740
if (!window.Visualforce) {
3841

@@ -69,13 +72,13 @@ function jsrMocks() {
6972
callback(result, event);
7073
}, mock.timeout);
7174
}
72-
}
75+
}]
7376

7477
};
7578
}
7679

7780
function jsr(jsrMocks, $q, $rootScope) {
78-
'ngInject';
81+
"ngInject";
7982

8083
var Visualforce = jsrMocks;
8184

dist/jsr-mocks.provider.js

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

index.html

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

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"main": "dist/jsr-mocks.angular.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"build": "babel jsr-mocks.angular.es6 --presets es2015 -o dist/jsr-mocks.provider.js"
8+
"prebuild": "rm dist/jsr-mocks.angular.js",
9+
"build": "babel src/jsr-mocks.angular.es6 -o dist/jsr-mocks.angular.js",
10+
"postbuild": "ng-annotate -a dist/jsr-mocks.angular.js -o dist/jsr-mocks.angular.js"
911
},
1012
"repository": {
1113
"type": "git",
@@ -19,6 +21,7 @@
1921
"homepage": "https://github.com/dshahin/jsr-mocks#readme",
2022
"devDependencies": {
2123
"babel-cli": "6.14.0",
22-
"babel-preset-es2015": "6.14.0"
24+
"babel-preset-es2015": "6.14.0",
25+
"ng-annotate": "1.2.1"
2326
}
2427
}

jsr-mocks.angular.es6 renamed to src/jsr-mocks.angular.es6

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var genericMock ={
1111
};
1212

1313
function jsrMocks() {
14+
"ngInject";
1415
var $mocks;
1516
var $mockServer;
1617
return {
@@ -20,7 +21,7 @@ function jsrMocks() {
2021
},
2122

2223
$get: function ($timeout) {
23-
'ngInject';
24+
"ngInject";
2425
if (!window.Visualforce) {
2526

2627
return {
@@ -53,7 +54,7 @@ function jsrMocks() {
5354
if (typeof (callback) === 'object') {
5455
callback = arguments[arguments.length - 2];
5556
}
56-
$timeout(function () {
57+
$timeout( () => {
5758
callback(result, event);
5859
}, mock.timeout);
5960
}
@@ -65,7 +66,7 @@ function jsrMocks() {
6566
}
6667

6768
function jsr(jsrMocks, $q, $rootScope) {
68-
'ngInject';
69+
"ngInject";
6970
var Visualforce = jsrMocks;
7071

7172
return function (request) {
@@ -79,8 +80,8 @@ function jsr(jsrMocks, $q, $rootScope) {
7980
parameters.push(request.args[i]);
8081
}
8182
}
82-
var callback = function (result, event) {
83-
$rootScope.$apply(function () {
83+
var callback = (result, event) => {
84+
$rootScope.$apply( () => {
8485
if (event.status) {
8586
deferred.resolve(result);
8687
} else {

0 commit comments

Comments
 (0)