Skip to content

Commit

Permalink
Apply Prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Jan 20, 2021
1 parent 7f4c5a1 commit c02729f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 4,
"semi": true,
"singleQuote": true
}
10 changes: 5 additions & 5 deletions src/stubs/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
// https://on.cypress.io/configuration
// ***********************************************************

import './commands'
import './commands';
import './laravel-commands';
import './assertions';

before(() => {
cy.task('activateCypressEnvFile', {}, {log: false});
cy.artisan('config:clear', {}, {log: false});
cy.task('activateCypressEnvFile', {}, { log: false });
cy.artisan('config:clear', {}, { log: false });
});

after(() => {
cy.task('activateLocalEnvFile', {}, {log: false});
cy.artisan('config:clear', {}, {log: false});
cy.task('activateLocalEnvFile', {}, { log: false });
cy.artisan('config:clear', {}, { log: false });
});
65 changes: 33 additions & 32 deletions src/stubs/support/laravel-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,45 @@
* @example cy.login();
* cy.login({ name: 'JohnDoe' });
*/
Cypress.Commands.add("login", (attributes = {}) => {
Cypress.Commands.add('login', (attributes = {}) => {
return cy
.csrfToken()
.then((token) => {
return cy.request({
method: "POST",
url: "/__cypress__/login",
method: 'POST',
url: '/__cypress__/login',
body: { attributes, _token: token },
log: false,
});
})
.then(({ body }) => {
Cypress.log({
name: "login",
name: 'login',
message: attributes,
consoleProps: () => ({ user: body }),
});
})
.its("body", { log: false });
.its('body', { log: false });
});

/**
* Logout the current user.
*
* @example cy.logout();
*/
Cypress.Commands.add("logout", () => {
Cypress.Commands.add('logout', () => {
return cy
.csrfToken()
.then((token) => {
return cy.request({
method: "POST",
url: "/__cypress__/logout",
method: 'POST',
url: '/__cypress__/logout',
body: { _token: token },
log: false,
});
})
.then(() => {
Cypress.log({ name: "logout", message: "" });
Cypress.log({ name: 'logout', message: '' });
});
});

Expand All @@ -53,14 +53,14 @@ Cypress.Commands.add("logout", () => {
*
* @example cy.csrfToken();
*/
Cypress.Commands.add("csrfToken", () => {
Cypress.Commands.add('csrfToken', () => {
return cy
.request({
method: "GET",
url: "/__cypress__/csrf_token",
method: 'GET',
url: '/__cypress__/csrf_token',
log: false,
})
.its("body", { log: false });
.its('body', { log: false });
});

/**
Expand All @@ -74,8 +74,8 @@ Cypress.Commands.add("csrfToken", () => {
* cy.create('App\\User', 2);
* cy.create('App\\User', 2, { active: false });
*/
Cypress.Commands.add("create", (model, times = 1, attributes = {}) => {
if (typeof times === "object") {
Cypress.Commands.add('create', (model, times = 1, attributes = {}) => {
if (typeof times === 'object') {
attributes = times;
times = 1;
}
Expand All @@ -84,20 +84,20 @@ Cypress.Commands.add("create", (model, times = 1, attributes = {}) => {
.csrfToken()
.then((token) => {
return cy.request({
method: "POST",
url: "/__cypress__/factory",
method: 'POST',
url: '/__cypress__/factory',
body: { attributes, model, times, _token: token },
log: false,
});
})
.then((response) => {
Cypress.log({
name: "create",
message: model + (times ? `(${times} times)` : ""),
name: 'create',
message: model + (times ? `(${times} times)` : ''),
consoleProps: () => ({ [model]: response.body }),
});
})
.its("body", { log: false });
.its('body', { log: false });
});

/**
Expand All @@ -108,8 +108,8 @@ Cypress.Commands.add("create", (model, times = 1, attributes = {}) => {
* @example cy.refreshDatabase();
* cy.refreshDatabase({ '--drop-views': true });
*/
Cypress.Commands.add("refreshDatabase", (options = {}) => {
return cy.artisan("migrate:fresh", options);
Cypress.Commands.add('refreshDatabase', (options = {}) => {
return cy.artisan('migrate:fresh', options);
});

/**
Expand All @@ -120,9 +120,9 @@ Cypress.Commands.add("refreshDatabase", (options = {}) => {
* @example cy.seed();
* cy.seed('PlansTableSeeder');
*/
Cypress.Commands.add("seed", (seederClass) => {
return cy.artisan("db:seed", {
"--class": seederClass,
Cypress.Commands.add('seed', (seederClass) => {
return cy.artisan('db:seed', {
'--class': seederClass,
});
});

Expand All @@ -131,6 +131,7 @@ Cypress.Commands.add("seed", (seederClass) => {
*
* @param {String} command
* @param {Object} parameters
* @param {Object} options
*
* @example cy.artisan('cache:clear');
*/
Expand All @@ -147,8 +148,8 @@ Cypress.Commands.add('artisan', (command, parameters = {}, options = {}) => {

return cy.csrfToken().then((token) => {
return cy.request({
method: "POST",
url: "/__cypress__/artisan",
method: 'POST',
url: '/__cypress__/artisan',
body: { command: command, parameters: parameters, _token: token },
log: false,
});
Expand All @@ -163,23 +164,23 @@ Cypress.Commands.add('artisan', (command, parameters = {}, options = {}) => {
* @example cy.php('2 + 2');
* cy.php('App\\User::count()');
*/
Cypress.Commands.add("php", (command) => {
Cypress.Commands.add('php', (command) => {
return cy
.csrfToken()
.then((token) => {
return cy.request({
method: "POST",
url: "/__cypress__/run-php",
method: 'POST',
url: '/__cypress__/run-php',
body: { command: command, _token: token },
log: false,
});
})
.then((response) => {
Cypress.log({
name: "php",
name: 'php',
message: command,
consoleProps: () => ({ result: response.body.result }),
});
})
.its("body.result", { log: false });
.its('body.result', { log: false });
});

0 comments on commit c02729f

Please sign in to comment.