Skip to content

Commit f26d016

Browse files
committed
Updated testing by adding subdomain and method.
1 parent 642f7c2 commit f26d016

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- updated: bundling skips all bundles with `-bk.bundle` in filename
88
- updated: bundle filenames are displayed in console
99
- updated: `UPDATE()` method by adding `noarchive` argument
10+
- updated: `TEST()` method supports `[subdomain]` keyword and `METHOD url` in URL address
1011

1112
- fixed: phone validation
1213

test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,29 @@ global.TEST = function(name, url, scope) {
116116
return;
117117
}
118118

119+
var subdomain;
120+
var method;
121+
var index = url.indexOf(' ');
122+
123+
if (index !== -1) {
124+
method = url.substring(0, index);
125+
url = url.substring(index + 1).trim();
126+
}
127+
128+
url = url.replace(/\[.*?]/g, function(text) {
129+
subdomain = text.replace(/\[|\]/g, '').trim();
130+
return '';
131+
});
132+
119133
if (!url.startsWith('http://', true) && !url.startsWith('https://', true))
120-
url = 'http://' + F.ip + ':' + F.port + (url[0] !== '/' ? '/' : '') + url;
134+
url = 'http://' + (subdomain ? (subdomain + '.') : '') + F.ip + ':' + F.port + (url[0] !== '/' ? '/' : '') + url;
121135

122136
var fn = function() {
123137
T.now = Date.now();
124138
T.currentname = name;
125139
T.current.count++;
126140
var builder = new RESTBuilder(url);
141+
method && builder.method(method);
127142
builder.header('X-Assertion-Testing', '1');
128143
scope.call(builder, builder);
129144
};

0 commit comments

Comments
 (0)