From 07d9916df18244b916826946e91c08ee6ace147d Mon Sep 17 00:00:00 2001 From: Narine <156703697+narinegi@users.noreply.github.com> Date: Tue, 7 May 2024 17:32:15 +0100 Subject: [PATCH] Add files via upload --- create-new-post.cy.js | 12 ++++++++++++ delete.cy.js | 10 ++++++++++ get-posts-list.cy.js | 10 ++++++++++ post-by-id.cy.js | 9 +++++++++ update-post-by-id.cy.js | 15 +++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 create-new-post.cy.js create mode 100644 delete.cy.js create mode 100644 get-posts-list.cy.js create mode 100644 post-by-id.cy.js create mode 100644 update-post-by-id.cy.js diff --git a/create-new-post.cy.js b/create-new-post.cy.js new file mode 100644 index 0000000..278949b --- /dev/null +++ b/create-new-post.cy.js @@ -0,0 +1,12 @@ +describe('Create New Post API Test API', () => { + it('should create new post', () => { + cy.api('POST', 'https://jsonplaceholder.typicode.com/posts', { + title: 'foo', + body: 'bar', + userId: 1, + }).should((response) => { + expect(response.status).to.eq(201); + expect(response.body).to.have.property('id'); + }); + }); +}); diff --git a/delete.cy.js b/delete.cy.js new file mode 100644 index 0000000..cd05772 --- /dev/null +++ b/delete.cy.js @@ -0,0 +1,10 @@ +describe('Delete Post by ID API Test API', () => { + it('should delete post by id', () => { + cy.api('DELETE', 'https://jsonplaceholder.typicode.com/posts/1') + .should((response) => { + expect(response.status).to.eq(200); + }); + }); +}); + + diff --git a/get-posts-list.cy.js b/get-posts-list.cy.js new file mode 100644 index 0000000..e68a047 --- /dev/null +++ b/get-posts-list.cy.js @@ -0,0 +1,10 @@ +describe('Get Posts List API Test API', () => { + it('should get posts list', () => { + cy.api('GET', 'https://jsonplaceholder.typicode.com/posts') + .should((response) => { + expect(response.status).to.eq(200); + expect(response.body.length).to.be.greaterThan(0); + }); + }); +}); + diff --git a/post-by-id.cy.js b/post-by-id.cy.js new file mode 100644 index 0000000..c1b0f33 --- /dev/null +++ b/post-by-id.cy.js @@ -0,0 +1,9 @@ +describe('Get Post by ID API Test API', () => { + it('should get post by id', () => { + cy.api('GET', 'https://jsonplaceholder.typicode.com/posts/1') + .should((response) => { + expect(response.status).to.eq(200); + expect(response.body).to.have.property('id', 1); + }); + }); +}); diff --git a/update-post-by-id.cy.js b/update-post-by-id.cy.js new file mode 100644 index 0000000..c94aa5c --- /dev/null +++ b/update-post-by-id.cy.js @@ -0,0 +1,15 @@ +describe('Update Post by ID API Test API', () => { + it('should update post by id', () => { + cy.api('PUT', 'https://jsonplaceholder.typicode.com/posts/1', { + id: 1, + title: 'foo', + body: 'bar', + userId: 1, + }).should((response) => { + expect(response.status).to.eq(200); + expect(response.body).to.have.property('title', 'foo'); + }); + }); +}); + +