8
8
// The module 'assert' provides assertion methods from node
9
9
import * as assert from "assert" ;
10
10
import * as path from "path" ;
11
- import { PathNormalizer } from "../pathNormalizer" ;
11
+ import { PathNormalizer , ResourceKind } from "../pathNormalizer" ;
12
12
import { Uri } from "vscode" ;
13
13
import { ISvnInfo } from "../common/types" ;
14
14
15
15
// Defines a Mocha test suite to group tests of similar kind together
16
- suite ( "Url parsing" , ( ) => {
16
+ suite ( "SVN URLs parsing" , ( ) => {
17
17
const ri1 = {
18
18
repository : {
19
19
root : "svn://somedomain.x.org/public/devs"
@@ -33,7 +33,7 @@ suite("Url parsing", () => {
33
33
// do nothing
34
34
} ) ;
35
35
36
- test ( "r1 ops " , function ( ) {
36
+ test ( "somedomain " , function ( ) {
37
37
assert . equal ( nm1 . branchRoot . toString ( ) , Uri . parse ( ri1 . url ) . toString ( ) ) ;
38
38
assert . equal (
39
39
nm1 . repoRoot . toString ( ) ,
@@ -52,5 +52,73 @@ suite("Url parsing", () => {
52
52
throw new Error ( "impossible" ) ;
53
53
}
54
54
assert . equal ( x1 . localFullPath . toString ( ) , "file:///home/d1/f1" ) ;
55
+ const x2 = nm1 . parse ( "/branches/features/F1/dir/file.c" ) ;
56
+ assert . equal (
57
+ x2 . localFullPath ! . toString ( ) ,
58
+ "file:///home/user/dev/mypero/dir/file.c"
59
+ ) ;
60
+ } ) ;
61
+
62
+ const ri2 = {
63
+ repository : {
64
+ root : "svn://rootdomain.com"
65
+ } ,
66
+ url : "svn://rootdomain.com/foo/drupal-7/trunk" ,
67
+ wcInfo : {
68
+ wcrootAbspath : "/home/dev-mi/projects/drupal/foo"
69
+ }
70
+ } ;
71
+ const nm2 = new PathNormalizer ( ri2 as ISvnInfo ) ;
72
+
73
+ test ( "rootdomain" , function ( ) {
74
+ const p1 = nm2 . parse (
75
+ "/foo/drupal-7/trunk/drupal/sites/all/themes/foo_theme/scss/foo-pdf.scss"
76
+ ) ;
77
+ assert . equal (
78
+ p1 . localFullPath ! . path ,
79
+ "/home/dev-mi/projects/drupal/foo/drupal/sites/all/themes/foo_theme/scss/foo-pdf.scss"
80
+ ) ;
81
+
82
+ const p2 = nm2 . parse ( "drupal/sites" , ResourceKind . LocalRelative ) ;
83
+ assert . equal ( p2 . remoteFullPath . path , "/foo/drupal-7/trunk/drupal/sites" ) ;
84
+ const p3 = nm2 . parse (
85
+ "/home/dev-mi/projects/drupal/foo/drupal" ,
86
+ ResourceKind . LocalFull
87
+ ) ;
88
+ assert . equal ( p3 . remoteFullPath . path , "/foo/drupal-7/trunk/drupal" ) ;
55
89
} ) ;
90
+
91
+ const ri3 = {
92
+ repository : {
93
+ root : "svn://rootdomain.com"
94
+ } ,
95
+ url : "svn://rootdomain.com" ,
96
+ wcInfo : {
97
+ wcrootAbspath : "/home/user/svn"
98
+ }
99
+ } ;
100
+ const nm3 = new PathNormalizer ( ri3 as ISvnInfo ) ;
101
+
102
+ test ( "rootbranch" , function ( ) {
103
+ const p4 = nm3 . parse ( "/file.c" ) ;
104
+ assert . equal ( p4 . localFullPath ! . path , "/home/user/svn/file.c" ) ;
105
+ } ) ;
106
+
107
+ const ri4 = {
108
+ repository : {
109
+ root : "svn://rootdomain.com"
110
+ } ,
111
+ url : "svn://rootdomain.com/trunk" ,
112
+ wcInfo : {
113
+ wcrootAbspath : "X:\\work\\rootd"
114
+ }
115
+ } ;
116
+ const nm4 = new PathNormalizer ( ri4 as ISvnInfo ) ;
117
+
118
+ if ( process . platform == "win32" ) {
119
+ test ( "winpath" , function ( ) {
120
+ const p4 = nm4 . parse ( "/trunk/file.c" ) ;
121
+ assert . equal ( p4 . localFullPath ! . fsPath , "x:\\work\\rootd\\file.c" ) ;
122
+ } ) ;
123
+ }
56
124
} ) ;
0 commit comments