From f0bc59dd0cfd468dccf5095c67586d67e41aeb55 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Wed, 14 Oct 2020 15:07:41 -0400 Subject: [PATCH] test: remove faker --- package.json | 1 - src/auth/auth.spec.js | 3 +-- src/collections/tests/collections.spec.js | 24 +++++++++++------------ src/collections/tests/hooks.spec.js | 11 +++++------ yarn.lock | 5 ----- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index b6e8d569b3..616921eb97 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,6 @@ "eslint-plugin-jsx-a11y": "^6.2.1", "eslint-plugin-react": "^7.18.0", "eslint-plugin-react-hooks": "^2.3.0", - "faker": "^4.1.0", "form-data": "^3.0.0", "graphql-request": "^2.0.0", "nodemon": "^1.19.4", diff --git a/src/auth/auth.spec.js b/src/auth/auth.spec.js index bf61da3f02..4ac63cc336 100644 --- a/src/auth/auth.spec.js +++ b/src/auth/auth.spec.js @@ -1,5 +1,4 @@ require('isomorphic-fetch'); -const faker = require('faker'); const { email, password } = require('../../tests/api/credentials'); /** @@ -99,7 +98,7 @@ describe('Users REST API', () => { it('should allow a user to be created', async () => { const response = await fetch(`${url}/api/admins`, { body: JSON.stringify({ - email: `${faker.name.firstName()}@test.com`, + email: 'name@test.com', password, roles: ['editor'], }), diff --git a/src/collections/tests/collections.spec.js b/src/collections/tests/collections.spec.js index 05be7e7934..895ef961d4 100644 --- a/src/collections/tests/collections.spec.js +++ b/src/collections/tests/collections.spec.js @@ -1,5 +1,5 @@ require('isomorphic-fetch'); -const faker = require('faker'); +const uuid = require('uuid').v4; const getConfig = require('../../utilities/getConfig'); const { email, password } = require('../../../tests/api/credentials'); @@ -9,8 +9,8 @@ let token = null; let headers = null; let localizedPostID; -const englishPostDesc = faker.lorem.lines(2); -const spanishPostDesc = faker.lorem.lines(2); +const englishPostDesc = 'english description'; +const spanishPostDesc = 'spanish description'; describe('Collections - REST', () => { beforeAll(async (done) => { @@ -40,7 +40,7 @@ describe('Collections - REST', () => { it('should allow a localized post to be created', async () => { const response = await fetch(`${url}/api/localized-posts`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: englishPostDesc, priority: 1, }), @@ -65,7 +65,7 @@ describe('Collections - REST', () => { it('should allow updating an existing post', async () => { const createResponse = await fetch(`${url}/api/localized-posts`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: 'original description', priority: 1, }), @@ -80,7 +80,7 @@ describe('Collections - REST', () => { const updatedDesc = 'updated description'; const response = await fetch(`${url}/api/localized-posts/${id}`, { body: JSON.stringify({ - title: 'asdf', + title: 'title', description: updatedDesc, priority: 1, }), @@ -97,7 +97,7 @@ describe('Collections - REST', () => { it('should allow a Spanish locale to be added to an existing post', async () => { const response = await fetch(`${url}/api/localized-posts/${localizedPostID}?locale=es`, { body: JSON.stringify({ - title: `Spanish-${faker.name.firstName()}`, + title: 'title', description: spanishPostDesc, priority: 1, }), @@ -151,8 +151,8 @@ describe('Collections - REST', () => { it('should allow querying by id', async () => { const response = await fetch(`${url}/api/localized-posts`, { body: JSON.stringify({ - title: faker.name.firstName(), - description: faker.lorem.lines(2), + title: 'title', + description: 'description', priority: 1, }), headers, @@ -175,7 +175,7 @@ describe('Collections - REST', () => { const desc = 'query test'; const response = await fetch(`${url}/api/localized-posts`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: desc, priority: 1, }), @@ -266,7 +266,7 @@ describe('Collections - REST', () => { it('should allow a post to be deleted', async () => { const response = await fetch(`${url}/api/localized-posts`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: englishPostDesc, priority: 1, }), @@ -293,7 +293,7 @@ describe('Collections - REST', () => { async function createPost(title, description) { await fetch(`${url}/api/localized-posts`, { body: JSON.stringify({ - title: title || faker.name.firstName(), + title: title || uuid(), description, priority: 1, }), diff --git a/src/collections/tests/hooks.spec.js b/src/collections/tests/hooks.spec.js index d5476b8716..d3dc1164d2 100644 --- a/src/collections/tests/hooks.spec.js +++ b/src/collections/tests/hooks.spec.js @@ -1,5 +1,4 @@ require('isomorphic-fetch'); -const faker = require('faker'); const getConfig = require('../../utilities/getConfig'); const { email, password } = require('../../../tests/api/credentials'); @@ -37,7 +36,7 @@ describe('Collections - REST', () => { it('beforeChange', async () => { const response = await fetch(`${url}/api/hooks`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: 'Original', priority: 1, }), @@ -55,7 +54,7 @@ describe('Collections - REST', () => { it('beforeDelete', async () => { const createResponse = await fetch(`${url}/api/hooks`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: 'Original', priority: 1, }), @@ -84,7 +83,7 @@ describe('Collections - REST', () => { it('afterRead', async () => { const response = await fetch(`${url}/api/hooks`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: 'afterRead', priority: 1, }), @@ -104,7 +103,7 @@ describe('Collections - REST', () => { it('afterChange', async () => { const createResponse = await fetch(`${url}/api/hooks`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: 'Original', priority: 1, }), @@ -133,7 +132,7 @@ describe('Collections - REST', () => { it('afterDelete', async () => { const createResponse = await fetch(`${url}/api/hooks`, { body: JSON.stringify({ - title: faker.name.firstName(), + title: 'title', description: 'Original', priority: 1, }), diff --git a/yarn.lock b/yarn.lock index 8aa43e3b8c..cd97682a8e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5274,11 +5274,6 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= -faker@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f" - integrity sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8= - "falsey@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/falsey/-/falsey-1.0.0.tgz#71bdd775c24edad9f2f5c015ce8be24400bb5d7d"