@anu8151/adonisjs-blueprint 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -27,10 +27,17 @@ var TestGenerator = class extends BaseGenerator {
|
|
|
27
27
|
auth: !!typedDef.auth
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
const testLines = actions.map((action) => {
|
|
31
|
+
let logic = "";
|
|
32
|
+
if (action.auth) logic = `const user = await User.create({})\n const response = await client.${action.method}('${action.url}').loginAs(user)`;
|
|
33
|
+
else logic = `const response = await client.${action.method}('${action.url}')`;
|
|
34
|
+
return `test('${action.name}', async ({ client }) => {\n ${logic}\n response.assertStatus(200)\n })`;
|
|
35
|
+
}).join("\n\n ");
|
|
30
36
|
await this.generateStub("make/test/controller.stub", {
|
|
31
37
|
entity,
|
|
32
38
|
actions,
|
|
33
|
-
hasAuth: actions.some((a) => a.auth) || !!blueprint.auth
|
|
39
|
+
hasAuth: actions.some((a) => a.auth) || !!blueprint.auth,
|
|
40
|
+
testLines
|
|
34
41
|
});
|
|
35
42
|
}
|
|
36
43
|
};
|
|
@@ -9,15 +9,5 @@ import User from '#models/user'
|
|
|
9
9
|
@end
|
|
10
10
|
|
|
11
11
|
test.group('{{ entity.className }} Controller', () => {
|
|
12
|
-
|
|
13
|
-
test('{{ action.name }}', async ({ client }) => {
|
|
14
|
-
@if(action.auth)
|
|
15
|
-
const user = await User.create({})
|
|
16
|
-
const response = await client.{{ action.method }}('{{ action.url }}').loginAs(user)
|
|
17
|
-
@else
|
|
18
|
-
const response = await client.{{ action.method }}('{{ action.url }}')
|
|
19
|
-
@end
|
|
20
|
-
response.assertStatus(200)
|
|
21
|
-
})
|
|
22
|
-
@end
|
|
12
|
+
{{{ testLines }}}
|
|
23
13
|
})
|
package/package.json
CHANGED
|
@@ -9,15 +9,5 @@ import User from '#models/user'
|
|
|
9
9
|
@end
|
|
10
10
|
|
|
11
11
|
test.group('{{ entity.className }} Controller', () => {
|
|
12
|
-
|
|
13
|
-
test('{{ action.name }}', async ({ client }) => {
|
|
14
|
-
@if(action.auth)
|
|
15
|
-
const user = await User.create({})
|
|
16
|
-
const response = await client.{{ action.method }}('{{ action.url }}').loginAs(user)
|
|
17
|
-
@else
|
|
18
|
-
const response = await client.{{ action.method }}('{{ action.url }}')
|
|
19
|
-
@end
|
|
20
|
-
response.assertStatus(200)
|
|
21
|
-
})
|
|
22
|
-
@end
|
|
12
|
+
{{{ testLines }}}
|
|
23
13
|
})
|