We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5b5789b commit 1ff8891Copy full SHA for 1ff8891
1 file changed
chromium/test/testing_utils.js
@@ -0,0 +1,29 @@
1
+'use strict'
2
+
3
+function Mock() {
4
+ let out = function() {
5
+ out.calledWith = Array.from(arguments);
6
+ }
7
+ return out;
8
+}
9
10
+function stub(name, value) {
11
+ let parts = name.split('.'),
12
+ last = parts.pop(),
13
+ part = global;
14
+ parts.forEach(partName => {
15
+ if (!part.hasOwnProperty(partName)) {
16
+ part[partName] = {};
17
18
+ part = part[partName];
19
+ });
20
+ part[last] = value;
21
22
23
+function stubber(namesValues) {
24
+ namesValues.forEach(nameValue => {
25
+ stub(...nameValue);
26
27
28
29
+Object.assign(exports, {Mock, stub, stubber});
0 commit comments