Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ Note this does not yet all lint. Working on it.
### Testing

Due to difficulties in testing packages with "peer" NPM dependencies, we've worked around by moving package tests into harness test apps. You can find them in `tests/`.

To run tests for a Meteor react package, navigate to its `tests/*` app and execute `npm test`.
11 changes: 0 additions & 11 deletions packages/react-meteor-accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,5 @@
"name": "meteor-react-accounts",
"scripts": {
"make-types": "npx typescript react-accounts.tsx --jsx preserve --declaration --emitDeclarationOnly --esModuleInterop --outDir types --strict"
},
"devDependencies": {
"@testing-library/react": "^10.0.2",
"@testing-library/react-hooks": "^7.0.2",
"@tsconfig/recommended": "^1.0.1",
"@types/meteor": "^1.4.42",
"@types/react": "^16.9.34",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-test-renderer": "16.13.1",
"typescript": "^4.0.3"
}
}
18 changes: 4 additions & 14 deletions packages/react-meteor-accounts/react-accounts.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
// Prepare method for clearing DB (doesn't need to be isomorphic).
if (Meteor.isServer) {
Meteor.methods({
reset() {
Meteor.users.remove({});
async reset() {
await Meteor.users.removeAsync({});
},
});
}
Expand Down Expand Up @@ -54,19 +54,9 @@ if (Meteor.isClient) {
// common test arrangements
async function beforeEach() {
// reset DB; must complete before creation to avoid potential overlap
await new Promise((resolve, reject) => {
Meteor.call("reset", (error, result) => {
if (error) reject(error);
else resolve(result);
});
});
await Meteor.callAsync("reset");
// prepare sample user
await new Promise<void>((resolve, reject) => {
Accounts.createUser({ username, password }, (error) => {
if (error) reject(error);
else resolve();
});
});
await Accounts.createUserAsync({ username, password });
// logout since `createUser` auto-logs-in
await logout();
}
Expand Down
3 changes: 2 additions & 1 deletion packages/react-meteor-data/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ Package.onTest((api) => {
api.use(['ecmascript', 'typescript', 'reactive-dict', 'reactive-var', 'tracker', 'tinytest', 'underscore', 'mongo'])
api.use('test-helpers')
api.use('react-meteor-data')
api.mainModule('tests.js')

api.mainModule('tests.js');
})
17 changes: 1 addition & 16 deletions packages/react-meteor-data/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
{
"name": "react-meteor-data",
"dependencies": {
"@testing-library/react": "^12.0.0",
"@types/meteor": "^1.4.76",
"@types/react": "^17.0.16",
"fast-deep-equal": "^3.1.3",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-test-renderer": "17.0.2",
"lodash.isequal": "^4.5.0",
"lodash.remove": "^4.7.0"
},
"devDependencies": {
"@types/lodash.isequal" : "^4.5.4",
"@types/lodash.remove" : "^4.7.5"
}
"name": "react-meteor-data"
}
6 changes: 2 additions & 4 deletions packages/react-meteor-data/useFind.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ if (Meteor.isClient) {

await waitFor(() => {}, { container, timeout: 250 })

test.equal(renders, 10, '10 items should have rendered - the initial list is always tossed.')

await waitFor(() => {
TestDocs.update({ id: 2 }, { $inc: { updated: 1 } })
}, { container, timeout: 250 })

test.equal(renders, 11, '11 items should have rendered - only 1 of the items should have been matched by the reconciler after a single change.')
test.equal(renders, 6, '6 items should have rendered - only 1 of the items should have been matched by the reconciler after a single change.')

completed()
})
Expand Down Expand Up @@ -104,7 +102,7 @@ if (Meteor.isClient) {
setReturnNull(false)

await waitFor(() => {}, { container, timeout: 250 })
test.isNotNull(returnValue, 'Return value should be null when the factory returns null')
test.equal(returnValue.length, 1, 'Return value should be an array with one document')

completed()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ notices-for-facebook-graph-api-2
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
1.4.0-remove-old-dev-bundle-link
1.4.1-add-shell-server-package
1.4.3-split-account-service-packages
1.5-add-dynamic-import-package
1.7-split-underscore-from-meteor-base
1.8.3-split-jquery-from-blaze
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

193gboe1tus04g9q8fl2
xi4ob9zualf.vxwytungbgj
19 changes: 19 additions & 0 deletions tests/react-meteor-accounts-harness/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base@1.5.2 # Packages every Meteor app needs to have
mobile-experience@1.1.2 # Packages for a great mobile UX
mongo@2.1.0 # The database Meteor supports right now
static-html@1.4.0 # Define static page content in .html files
reactive-var@1.0.13 # Reactive variable for tracker
tracker@1.3.4 # Meteor's client-side reactive programming library

standard-minifier-css@1.9.3 # CSS minifier run for production mode
standard-minifier-js@3.0.0 # JS minifier run for production mode
es5-shim@4.8.1 # ECMAScript 5 compatibility for older browsers
ecmascript@0.16.10 # Enable ECMAScript2015+ syntax in app code
typescript@5.6.3 # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.6.1 # Server-side component of the `meteor shell` command
1 change: 1 addition & 0 deletions tests/react-meteor-accounts-harness/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
METEOR@3.1.2
64 changes: 64 additions & 0 deletions tests/react-meteor-accounts-harness/.meteor/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
allow-deny@2.1.0
autoupdate@2.0.0
babel-compiler@7.11.3
babel-runtime@1.5.2
base64@1.0.13
binary-heap@1.0.12
boilerplate-generator@2.0.0
caching-compiler@2.0.1
callback-hook@1.6.0
check@1.4.4
core-runtime@1.0.0
ddp@1.4.2
ddp-client@3.1.0
ddp-common@1.4.4
ddp-server@3.1.0
diff-sequence@1.1.3
dynamic-import@0.7.4
ecmascript@0.16.10
ecmascript-runtime@0.8.3
ecmascript-runtime-client@0.12.2
ecmascript-runtime-server@0.11.1
ejson@1.1.4
es5-shim@4.8.1
facts-base@1.0.2
fetch@0.1.5
geojson-utils@1.0.12
hot-code-push@1.0.5
id-map@1.2.0
inter-process-messaging@0.1.2
launch-screen@2.0.1
logging@1.3.5
meteor@2.1.0
meteor-base@1.5.2
minifier-css@2.0.0
minifier-js@3.0.1
minimongo@2.0.2
mobile-experience@1.1.2
mobile-status-bar@1.1.1
modern-browsers@0.2.0
modules@0.20.3
modules-runtime@0.13.2
mongo@2.1.0
mongo-decimal@0.2.0
mongo-dev-server@1.1.1
mongo-id@1.0.9
npm-mongo@6.10.2
ordered-dict@1.2.0
promise@1.0.0
random@1.2.2
react-fast-refresh@0.2.9
reactive-var@1.0.13
reload@1.3.2
retry@1.1.1
routepolicy@1.1.2
shell-server@0.6.1
socket-stream-client@0.6.0
standard-minifier-css@1.9.3
standard-minifier-js@3.0.0
static-html@1.4.0
static-html-tools@1.0.0
tracker@1.3.4
typescript@5.6.3
webapp@2.0.5
webapp-hashing@1.1.2
Loading