|
1 | 1 | import { expect } from 'chai'
|
2 | 2 | import { StartTransformRequest, TransformProjectMetadata } from '../models'
|
3 |
| -import { isProject, isSolution, validateProject } from '../validation' |
| 3 | +import { isProject, isSolution, validateProject, validateSolution } from '../validation' |
4 | 4 | import { supportedProjects, unsupportedViewComponents } from '../resources/SupportedProjects'
|
5 | 5 | import mock = require('mock-fs')
|
6 | 6 | import { Logging } from '@aws/language-server-runtimes/server-interface'
|
@@ -96,4 +96,72 @@ describe('Test validation functionality', () => {
|
96 | 96 |
|
97 | 97 | expect(validateProject(mockStartTransformationRequest, mockedLogging)).to.equal(false)
|
98 | 98 | })
|
| 99 | + |
| 100 | + // New tests for AspNetWebForms validation |
| 101 | + it('should return true when project is AspNetWebForms type', () => { |
| 102 | + let mockStartTransformationRequest: StartTransformRequest = sampleStartTransformRequest |
| 103 | + const mockProjectMeta = { |
| 104 | + Name: '', |
| 105 | + ProjectTargetFramework: '', |
| 106 | + ProjectPath: 'test.csproj', |
| 107 | + SourceCodeFilePaths: [], |
| 108 | + ProjectLanguage: '', |
| 109 | + ProjectType: 'AspNetWebForms', |
| 110 | + ExternalReferences: [], |
| 111 | + } |
| 112 | + mockStartTransformationRequest.ProjectMetadata = [] |
| 113 | + mockStartTransformationRequest.ProjectMetadata.push(mockProjectMeta) |
| 114 | + |
| 115 | + expect(validateProject(mockStartTransformationRequest, mockedLogging)).to.equal(true) |
| 116 | + }) |
| 117 | + |
| 118 | + it('should not include AspNetWebForms in unsupported projects list', () => { |
| 119 | + let mockStartTransformationRequest: StartTransformRequest = sampleStartTransformRequest |
| 120 | + |
| 121 | + // Add a supported project |
| 122 | + const supportedProjectMeta = { |
| 123 | + Name: 'Supported', |
| 124 | + ProjectTargetFramework: '', |
| 125 | + ProjectPath: 'supported.csproj', |
| 126 | + SourceCodeFilePaths: [], |
| 127 | + ProjectLanguage: '', |
| 128 | + ProjectType: 'AspNetCoreMvc', |
| 129 | + ExternalReferences: [], |
| 130 | + } |
| 131 | + |
| 132 | + // Add an unsupported project |
| 133 | + const unsupportedProjectMeta = { |
| 134 | + Name: 'Unsupported', |
| 135 | + ProjectTargetFramework: '', |
| 136 | + ProjectPath: 'unsupported.csproj', |
| 137 | + SourceCodeFilePaths: [], |
| 138 | + ProjectLanguage: '', |
| 139 | + ProjectType: 'UnsupportedType', |
| 140 | + ExternalReferences: [], |
| 141 | + } |
| 142 | + |
| 143 | + // Add an AspNetWebForms project |
| 144 | + const webFormsProjectMeta = { |
| 145 | + Name: 'WebForms', |
| 146 | + ProjectTargetFramework: '', |
| 147 | + ProjectPath: 'webforms.csproj', |
| 148 | + SourceCodeFilePaths: [], |
| 149 | + ProjectLanguage: '', |
| 150 | + ProjectType: 'AspNetWebForms', |
| 151 | + ExternalReferences: [], |
| 152 | + } |
| 153 | + |
| 154 | + mockStartTransformationRequest.ProjectMetadata = [ |
| 155 | + supportedProjectMeta, |
| 156 | + unsupportedProjectMeta, |
| 157 | + webFormsProjectMeta, |
| 158 | + ] |
| 159 | + |
| 160 | + const unsupportedProjects = validateSolution(mockStartTransformationRequest) |
| 161 | + |
| 162 | + // Should only contain the unsupported project, not the AspNetWebForms project |
| 163 | + expect(unsupportedProjects).to.have.lengthOf(1) |
| 164 | + expect(unsupportedProjects[0]).to.equal('unsupported.csproj') |
| 165 | + expect(unsupportedProjects).to.not.include('webforms.csproj') |
| 166 | + }) |
99 | 167 | })
|
0 commit comments