Skip to content

Commit b8198b7

Browse files
committed
Add an advanced typescript test case
1 parent 7231285 commit b8198b7

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

test/fixtures/typescript-advanced/.disable-pnp

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const testSetup = require('../__shared__/test-setup');
2+
3+
test('builds in development', async () => {
4+
const { fulfilled, ...rest } = await testSetup.scripts.start({ smoke: true });
5+
expect(fulfilled).toBe(true);
6+
});
7+
test('builds in production', async () => {
8+
const { fulfilled } = await testSetup.scripts.build();
9+
expect(fulfilled).toBe(true);
10+
});
11+
test('passes tests', async () => {
12+
const { fulfilled } = await testSetup.scripts.test({
13+
jestEnvironment: 'node',
14+
});
15+
expect(fulfilled).toBe(true);
16+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"dependencies": {
3+
"@types/react": "*",
4+
"@types/react-dom": "*",
5+
"react": "*",
6+
"react-dom": "*",
7+
"typescript": "3.1.3"
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import App from './App';
2+
3+
it('reads a typescript file with no syntax error', () => {
4+
const app = new App();
5+
expect(App.foo.bar).toBe(true);
6+
expect(App.foo.baz!.n).toBe(123);
7+
expect(app.n).toBe(123);
8+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as React from 'react';
2+
3+
interface MyType {
4+
foo: number;
5+
bar: boolean;
6+
baz?: { n: number };
7+
}
8+
9+
type MyObject = Pick<MyType, 'bar' | 'baz'>;
10+
11+
class App extends React.Component {
12+
static foo: MyObject = { bar: true, baz: { n: 123 } };
13+
n = App.foo.baz!.n;
14+
15+
render() {
16+
return <div />;
17+
}
18+
}
19+
20+
export default App;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as React from 'react';
2+
import * as ReactDOM from 'react-dom';
3+
import App from './App';
4+
5+
ReactDOM.render(<App />, document.getElementById('root'));

0 commit comments

Comments
 (0)