diff --git a/test/typescript.js b/test/typescript.js index e567874..aa9d8f6 100644 --- a/test/typescript.js +++ b/test/typescript.js @@ -26,3 +26,77 @@ test('typescript', (t) => { ], }) }) + +test('typescript 2', (t) => { + t.plan(1) + const source = stripIndent` + describe('TypeScript spec', () => { + it('works', () => { + const person = { + name: 'Joe', + } + + cy.wrap(person).should('have.property', 'name', 'Joe') + }) + + it('loads', () => { + const n: number = 1 + cy.wrap(n).should('eq', 1) + }) + }) + ` + const result = getTestNames(source) + + t.deepEqual(result, { + suiteNames: ['TypeScript spec'], + testNames: ['loads', 'works'], + tests: [ + { + name: 'works', + }, + { + name: 'loads', + }, + { + name: 'TypeScript spec', + }, + ], + }) +}) + +// SKIP: https://github.com/bahmutov/find-test-names/issues/8 +test.skip('typescript interface', (t) => { + t.plan(1) + const source = stripIndent` + interface Person { + name: string + } + ` + const result = getTestNames(source) + + t.deepEqual(result, {}) +}) + +// SKIP: https://github.com/bahmutov/find-test-names/issues/8 +test.skip('typescript type', (t) => { + t.plan(1) + const source = stripIndent` + type Person = { + name: string + } + ` + const result = getTestNames(source) + + t.deepEqual(result, { + suiteNames: ['foo'], + testNames: ['bar'], + tests: [ + { + name: 'bar', + }, + { + name: 'foo', + }, + ], + }) +})