Skip to content

refactor: Reorganize type definition test files #2488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@semantic-release/npm": "12.0.1",
"@semantic-release/release-notes-generator": "14.0.3",
"@types/facebook-js-sdk": "3.3.11",
"@types/jest": "29.5.14",
"babel-jest": "29.5.0",
"babel-plugin-inline-package-json": "2.0.0",
"babel-plugin-minify-dead-code-elimination": "0.5.2",
Expand Down Expand Up @@ -108,7 +109,7 @@
"posttest:mongodb": "mongodb-runner stop --all",
"lint": "eslint --cache src/ integration/",
"lint:fix": "eslint --fix --cache src/ integration/",
"test:types": "eslint types/tests.ts -c eslint.config.test.mjs",
"test:types": "eslint types/tests/ -c ./types/eslint.config.mjs",
"watch": "cross-env PARSE_BUILD=${PARSE_BUILD} gulp watch",
"watch:browser": "cross-env PARSE_BUILD=browser npm run watch",
"watch:node": "cross-env PARSE_BUILD=node npm run watch",
Expand Down
File renamed without changes.
34 changes: 0 additions & 34 deletions types/tests.ts → types/tests/Parse-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2079,40 +2079,6 @@ function testRole() {
}
}

function testSession() {
async function testConstructor() {
// $ExpectType ParseSession<Attributes>
const session = new Parse.Session();

// $ExpectType ParseSession<{ example: number; }>
new Parse.Session({ example: 100 });

// $ExpectType ParseSession<{ example: number; }>
new Parse.Session<{ example: number }>();

// $ExpectType ParseSession<{ example: number; }>
new Parse.Session<{ example: number }>({ example: 100 });

// $ExpectError
new Parse.Session<{ example: number }>({ example: 'hello' });

// $ExpectType boolean
Parse.Session.isCurrentSessionRevocable();

// $ExpectType string[]
Parse.Session.readOnlyAttributes();

// $ExpectType string
session.getSessionToken();

// $ExpectType ParseSession<Attributes>
await Parse.Session.current();

// $ExpectType ParseSession<{ example: string; }>
await Parse.Session.current<Parse.Session<{ example: string }>>();
}
}

function testUser() {
function testConstructor() {
// $ExpectType ParseUser<Attributes>
Expand Down
41 changes: 41 additions & 0 deletions types/tests/ParseSession-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Parse from 'parse';

describe('Parse.Session Type Definitions', () => {
it('constructor', () => {
// $ExpectType ParseSession<Attributes>
new Parse.Session();

// $ExpectType ParseSession<{ example: number; }>
new Parse.Session({ example: 100 });

// $ExpectType ParseSession<{ example: number; }>
new Parse.Session<{ example: number }>();

// $ExpectType ParseSession<{ example: number; }>
new Parse.Session<{ example: number }>({ example: 100 });

// $ExpectError
new Parse.Session<{ example: number }>({ example: 'hello' });
});

it('instance methods', () => {
const session = new Parse.Session();

// $ExpectType string
session.getSessionToken();
});

it('static methods', async () => {
// $ExpectType boolean
Parse.Session.isCurrentSessionRevocable();

// $ExpectType string[]
Parse.Session.readOnlyAttributes();

// $ExpectType ParseSession<Attributes>
await Parse.Session.current();

// $ExpectType ParseSession<{ example: string; }>
await Parse.Session.current<Parse.Session<{ example: string }>>();
});
});
4 changes: 2 additions & 2 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"types": [],
"types": ["jest"],
"noEmit": true,
"forceConsistentCasingInFileNames": true,

Expand All @@ -20,6 +20,6 @@
}
},
"include": [
"tests.ts"
"tests/**/*.ts"
]
}
Loading