Skip to content

Commit

Permalink
Add node versions 6, 10 and 14 to the unit tests (#465)
Browse files Browse the repository at this point in the history
* 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 <v-ikuleshov@microsoft.com>
  • Loading branch information
kuleshovilya and kuleshovilya authored Sep 13, 2021
1 parent 010b234 commit 08377d0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
17 changes: 15 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
strategy:
matrix:
'Node 6':
versionSpec: '6.x'
'Node 8':
versionSpec: '8.x'
'Node 10':
versionSpec: '10.x'
'Node 12':
versionSpec: '12.x'
'Node 14':
versionSpec: '14.x'

steps:
- task: NodeTool@0
inputs:
versionSpec: "8.x"
displayName: Install node 8
versionSpec: $(versionSpec)
displayName: Install node

# install dependencies
- script: npm install
Expand Down
12 changes: 10 additions & 2 deletions make.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require('shelljs/make');
var path = require('path');
var fs = require('fs');
var semver = require('semver');

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

target.units = function() {
target.build();

pushd('test');
var nodeVer = process.versions.node;

//check for node version, since installation strategy is different for node versions less than 8
if(semver.lt(nodeVer,'8.0.0')){
pushd('_build');
}
else{
pushd('test');
}
run('npm install ../_build');
popd();

Expand Down
5 changes: 4 additions & 1 deletion test/units/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import vsom = require('../../_build/VsoClient');
import WebApi = require('../../_build/WebApi');
import * as rm from '../../_build/node_modules/typed-rest-client/RestClient';
import { ApiResourceLocation } from '../../_build/interfaces/common/VsoBaseInterfaces';
import semver = require('semver');

describe('VSOClient Units', function () {
let rest: rm.RestClient;
Expand Down Expand Up @@ -180,7 +181,9 @@ describe('VSOClient Units', function () {

//Assert
assert.equal(res.apiVersion, '1');
assert.equal(res.requestUrl, 'https://dev.azure.com/testTemplate?min=Wed%2C%2019%20Oct%200208%2000%3A00%3A00%20GMT');
//Use different strings for Node 6 and 8, because of a varied response string
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';
assert.equal(res.requestUrl, expectedURL);
});

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

0 comments on commit 08377d0

Please sign in to comment.