Skip to content

Commit

Permalink
Add tests for TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
pahen committed Aug 26, 2017
1 parent c470dd2 commit 50eb3ca
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-env mocha */
'use strict';

const madge = require('../lib/api');
require('should');

describe('TypeScript', () => {
const dir = __dirname + '/typescript';

it('extracts module dependencies', (done) => {
madge(dir + '/import.ts').then((res) => {
res.obj().should.eql({
'import.ts': ['require.ts'],
'require.ts': ['export.ts'],
'export.ts': []
});
done();
}).catch(done);
});
});
7 changes: 7 additions & 0 deletions test/typescript/export.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ExportClass {
stringLength(s: string) {
return s.length;
}
}

export = ExportClass;
8 changes: 8 additions & 0 deletions test/typescript/import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import B from './require';

class ImportClass {
constructor(public greeting: string) { }
greet() {
return "<h1>" + this.greeting + "</h1>";
}
};
7 changes: 7 additions & 0 deletions test/typescript/require.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import x = require('./export');

export default class RequireClass {
stringLength(s: string) {
return s.length;
}
}

0 comments on commit 50eb3ca

Please sign in to comment.