Closed mille-nium closed 5 years ago
I'm confused about how to split this test to separate files, because it is taking almost 800 lines for now (cases only for two methods), so it gets hard to read.
\cc @belochub @nechaido @lundibundi
@mille-nium metatests@0.6.6
have released, if you want you can use test.resolves
,test.rejects
and also there is no need to write test.end()
at the end of async
tests.
Also, before/afterEach
now properly support promises.
@lundibundi thank you, I'll move everything to new version.
I have a proposal for a more declarative syntax to reduce boilerplate, though it's a matter for debate if it is more readable. Example:
[
// ... cases
{
name: 'no permission for category with subsystem/catalog',
record: {
Name: 'person2S2',
Subsystem: subsystems.S2,
},
category: 'Person',
user: users.S2.InsertOnlyUser,
error: EXPECTED_ERROR,
},
].forEach(({ name, record, category, user, error }) =>
test.test(`remoteProvider.create: ${name}`, async test => {
if (user) {
await login(user);
}
const creation = remoteProvider.create(category, record);
if (error) {
const error = await test.rejects(creation, EXPECTED_ERROR);
test.strictSame(error.code, EXPECTED_ERROR_CODE);
} else {
await test.resolves(creation);
}
})
);
@belochub @lundibundi @mille-nium WDYT?
@nechaido this idea has been mentioned already by @lundibundi, however, it seemed to me like more unreadable one, so I haven't changed it. In addition, there are cases, where tests can't be designed in this way (there is some additional preparation), so I'm not sure whether it is okay to write these tests in different ways. Though I can be mistaken.
Closes: https://github.com/metarhia/globalstorage/issues/333