Skip to content

Commit

Permalink
chore: convert to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed May 14, 2019
1 parent cb931c5 commit 471fdb9
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions test/acceptance/sln-app.test.js → test/acceptance/sln-app.test.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
var test = require('tap').test;
var path = require('path');
var sln = require('../../src/lib/sln');
import {test} from 'tap';
import * as path from 'path';
import * as sln from '../../src/lib/sln';

test('parseFoldersFromSln when passed an existant filename', function (t) {
var slnFile = 'test/acceptance/workspaces/sln-example-app/mySolution.sln';
var expected = JSON.stringify([
"dotnet2_new_mvc_project/new_mvc_project.csproj",
"WebApplication2/WebApplication2.csproj"
test('parseFoldersFromSln when passed an existent filename', (t) => {
const slnFile = 'test/acceptance/workspaces/sln-example-app/mySolution.sln';
const expected = JSON.stringify([
'dotnet2_new_mvc_project/new_mvc_project.csproj',
'WebApplication2/WebApplication2.csproj',
]);
var actual = JSON.stringify(sln.parsePathsFromSln(slnFile));
const actual = JSON.stringify(sln.parsePathsFromSln(slnFile));
t.equal(actual, expected, 'should parse & extract csproj folders');
t.end();
});

test('parseFoldersFromSln when non existant filename', function (t) {
var response;
var slnFile = 'test/acceptance/workspaces/sln-example-app/mySolution1.sln';
test('parseFoldersFromSln when non existent filename', (t) => {
let response;
const slnFile = 'test/acceptance/workspaces/sln-example-app/mySolution1.sln';
try {
response = sln.parsePathsFromSln(slnFile);
t.fail('an exception should be thrown');
}
catch (e) {
} catch (e) {
t.match(e.message, 'File not found: ', 'should throw exception');
t.equal(response, undefined, 'shouldnt return');
}
t.end();
});

test('parseFoldersFromSln when no supported files found', function (t) {
test('parseFoldersFromSln when no supported files found', (t) => {
let response;
const slnFile = 'test/acceptance/workspaces/sln-no-supported-files/mySolution1.sln';
try {
Expand All @@ -40,32 +39,32 @@ test('parseFoldersFromSln when no supported files found', function (t) {
t.end();
});

test('sln.updateArgs for existing sln with regular paths', function (t) {
var args = {options: {
test('sln.updateArgs for existing sln with regular paths', (t) => {
const args = {options: {
file: 'test/acceptance/workspaces/sln-example-app/mySolution.sln', _: []}};

sln.updateArgs(args);
t.notOk(args.options.file, '`file` option is removed');
args.options._.pop();
t.same(args.options._.map(function (r) { return path.basename(r); }),
t.same(args.options._.map((r) => path.basename(r)),
[ 'dotnet2_new_mvc_project', 'WebApplication2' ], 'args should be added');
t.end();
});

test('sln.updateArgs for existing sln with relative paths', function (t) {
var args = {options: {
test('sln.updateArgs for existing sln with relative paths', (t) => {
const args = {options: {
file: 'test/acceptance/workspaces/slnSolution.sln', _: []}};

sln.updateArgs(args);
t.notOk(args.options.file, '`file` option is removed');
args.options._.pop();
t.same(args.options._.map(function (r) { return path.basename(r); }),
t.same(args.options._.map((r) => path.basename(r)),
[ 'nuget-app', 'nuget-app-2.1'], 'args should be added');
t.end();
});

test('sln.updateArgs for sln with no relevant projects', function (t) {
var args = {options: {
test('sln.updateArgs for sln with no relevant projects', (t) => {
const args = {options: {
file: 'test/acceptance/workspaces/emptySolution.sln', _: []}};

try {
Expand All @@ -78,9 +77,8 @@ test('sln.updateArgs for sln with no relevant projects', function (t) {
t.end();
});


test('sln.updateArgs for non-existing sln', function (t) {
var args = {options: {file: 'non_existent', _: []}};
test('sln.updateArgs for non-existing sln', (t) => {
const args = {options: {file: 'non_existent', _: []}};

try {
sln.updateArgs(args);
Expand Down

0 comments on commit 471fdb9

Please sign in to comment.