1+ /// <reference path="../../../definitions/mocha.d.ts"/>
2+ /// <reference path="../../../definitions/node.d.ts"/>
3+
4+ import assert = require( 'assert' ) ;
5+ import trm = require( '../../lib/taskRunner' ) ;
6+ import path = require( 'path' ) ;
7+ import util = require( 'util' ) ;
8+
9+ // Paths aren't the same between compile time and run time. This will need some work
10+ let realrequire = require ;
11+ function myrequire ( module : string ) : any {
12+ return realrequire ( path . join ( __dirname , "../../../Tasks/NuGetInstaller/node_modules" , module ) ) ;
13+ }
14+ require = < typeof require > myrequire ;
15+
16+
17+ import locationHelper = require( 'nuget-task-common/LocationHelpers' ) ;
18+
19+ describe ( "Common-NuGetTaskCommon Suite" , ( ) => {
20+
21+ before ( done => {
22+ // init here
23+ done ( ) ;
24+ } ) ;
25+
26+ after ( function ( ) {
27+
28+ } ) ;
29+
30+ it ( "assume pkg service from visualtudio.com" , done => {
31+ locationHelper . assumeNuGetUriPrefixes ( "https://contoso.visualstudio.com/foo" )
32+ . then ( assumedPrefixes => {
33+ assert . strictEqual ( assumedPrefixes . length , 2 , "should have exactly two prefix results" ) ;
34+ assert ( assumedPrefixes . indexOf ( "https://contoso.pkgs.visualstudio.com/foo" ) !== - 1 , "should contain a pkgs host" ) ;
35+ assert ( assumedPrefixes . indexOf ( "https://contoso.visualstudio.com/foo" ) !== - 1 , "should contain the original string" ) ;
36+ done ( ) ;
37+ } )
38+ . fail ( done ) ;
39+ } ) ;
40+
41+ it ( "assume no pkg service from not visualtudio.com" , done => {
42+ locationHelper . assumeNuGetUriPrefixes ( "https://contoso.example.com/foo" )
43+ . then ( assumedPrefixes => {
44+ assert . strictEqual ( assumedPrefixes . length , 1 , "should have exactly one prefix result" )
45+ assert ( assumedPrefixes . indexOf ( "https://contoso.example.com/foo" ) !== - 1 , "should contain the original string" ) ;
46+ done ( ) ;
47+ } )
48+ . fail ( done )
49+ } ) ;
50+
51+ it ( "assume no pkg service from localhost" , done => {
52+ locationHelper . assumeNuGetUriPrefixes ( "https://localhost/foo" )
53+ . then ( assumedPrefixes => {
54+ assert . strictEqual ( assumedPrefixes . length , 1 , "should have exactly one prefix result" )
55+ assert ( assumedPrefixes . indexOf ( "https://localhost/foo" ) !== - 1 , "should contain the original string" ) ;
56+ done ( ) ;
57+ } )
58+ . fail ( done ) ;
59+ } ) ;
60+ } ) ;
0 commit comments