Skip to content

Commit 08377d0

Browse files
authored
Add node versions 6, 10 and 14 to the unit tests (#465)
* add 6 10 14 node versions * remove node 6 * try running matrix * add node 6 * try test with g * try both * try with save dev * try 7 * try with changed make.js * change test string * try another date * try another date * fix typo * change string according to ver * fix typo * fix string * reduce duplication of commands * add comment for a different strings Co-authored-by: Ilya Kuleshov <[email protected]>
1 parent 010b234 commit 08377d0

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

azure-pipelines.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
strategy:
2+
matrix:
3+
'Node 6':
4+
versionSpec: '6.x'
5+
'Node 8':
6+
versionSpec: '8.x'
7+
'Node 10':
8+
versionSpec: '10.x'
9+
'Node 12':
10+
versionSpec: '12.x'
11+
'Node 14':
12+
versionSpec: '14.x'
13+
114
steps:
215
- task: NodeTool@0
316
inputs:
4-
versionSpec: "8.x"
5-
displayName: Install node 8
17+
versionSpec: $(versionSpec)
18+
displayName: Install node
619

720
# install dependencies
821
- script: npm install

make.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require('shelljs/make');
22
var path = require('path');
33
var fs = require('fs');
4+
var semver = require('semver');
45

56
var rp = function(relPath) {
67
return path.join(__dirname, relPath);
@@ -41,8 +42,15 @@ target.build = function() {
4142

4243
target.units = function() {
4344
target.build();
44-
45-
pushd('test');
45+
var nodeVer = process.versions.node;
46+
47+
//check for node version, since installation strategy is different for node versions less than 8
48+
if(semver.lt(nodeVer,'8.0.0')){
49+
pushd('_build');
50+
}
51+
else{
52+
pushd('test');
53+
}
4654
run('npm install ../_build');
4755
popd();
4856

test/units/tests.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import vsom = require('../../_build/VsoClient');
66
import WebApi = require('../../_build/WebApi');
77
import * as rm from '../../_build/node_modules/typed-rest-client/RestClient';
88
import { ApiResourceLocation } from '../../_build/interfaces/common/VsoBaseInterfaces';
9+
import semver = require('semver');
910

1011
describe('VSOClient Units', function () {
1112
let rest: rm.RestClient;
@@ -180,7 +181,9 @@ describe('VSOClient Units', function () {
180181

181182
//Assert
182183
assert.equal(res.apiVersion, '1');
183-
assert.equal(res.requestUrl, 'https://dev.azure.com/testTemplate?min=Wed%2C%2019%20Oct%200208%2000%3A00%3A00%20GMT');
184+
//Use different strings for Node 6 and 8, because of a varied response string
185+
var expectedURL = semver.lt(process.versions.node, '8.0.0') ? 'https://dev.azure.com/testTemplate?min=Wed%2C%2019%20Oct%20%20208%2000%3A00%3A00%20GMT' : 'https://dev.azure.com/testTemplate?min=Wed%2C%2019%20Oct%200208%2000%3A00%3A00%20GMT';
186+
assert.equal(res.requestUrl, expectedURL);
184187
});
185188

186189
it('gets versioning data after an initialization promise', async () => {

0 commit comments

Comments
 (0)