/
SpecificTestCases.ReferencesPart5.cs
80 lines (75 loc) · 2.7 KB
/
SpecificTestCases.ReferencesPart5.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Collections.Generic;
using System.IO;
using Reinforced.Typings.Fluent;
using Xunit;
namespace Reinforced.Typings.Tests.SpecificCases
{
public partial class SpecificTestCases
{
[Fact]
public void ReferencesPart5()
{
/**
* How let's make some noise with discarding namespaces
*
* Import tu Stuff appeared as specified it explicitly
*
* SomeIndirectlyReferencedClass exported within its namespace as we are using modules without
* discarding namespaces
*
* SomeFluentReferencedType is exported without namespace as we have explicitly specified it
*
* Also I've added nullable enum property just in case
*/
const string file1 = @"
///<reference path=""../../jquery.d.ts""/>
import * as Stuff from '../Stuff/Stuff';
import * as '$' from 'JQuery';
export namespace Reinforced.Typings.Tests.SpecificCases {
export class AnothreReferencingType
{
public Property: Stuff.SomeFluentReferencedType;
public Enum?: Stuff.SomeIndirectEnum;
public Indirect() : Stuff.Reinforced.Typings.Tests.SpecificCases.SomeIndirectlyReferencedClass
{
return null;
}
}
}";
const string file2 = @"
export namespace Reinforced.Typings.Tests.SpecificCases {
export class SomeIndirectlyReferencedClass
{
}
}
export class SomeFluentReferencedType
{
}
export enum SomeIndirectEnum {
One = 0,
Two = 1,
Three = 2
}";
AssertConfiguration(s =>
{
s.Global(a => a.DontWriteWarningComment().UseModules(discardNamespaces: false));
s.ExportAsClass<AnothreReferencingType>()
.AddReference(typeof(SomeFluentReferencedType))
.AddReference(typeof(SomeFluentlyReferencedNotExported))
.AddImport("* as Stuff", "../Stuff/Stuff")
.ExportTo("Exported/File1.ts")
.WithPublicMethods()
.WithPublicProperties()
.WithProperty(c => c.Enum, c => c.ForceNullable())
;
s.ExportAsClass<SomeIndirectlyReferencedClass>().ExportTo("Stuff/Stuff.ts");
s.ExportAsClass<SomeFluentReferencedType>().DontIncludeToNamespace().ExportTo("Stuff/Stuff.ts");
s.ExportAsEnum<SomeIndirectEnum>().DontIncludeToNamespace().ExportTo("Stuff/Stuff.ts");
}, new Dictionary<string, string>
{
{ Path.Combine(TargetDir, "Exported", "File1.ts"), file1},
{ Path.Combine(TargetDir, "Stuff", "Stuff.ts"), file2}
}, compareComments: true);
}
}
}