$kind: http-request
description: Get list of all economic activities
url: "{{csmisUrl}}/cooperative/members/page"
method: POST
body:
  type: json
  content: "{\r

    \    \"pageSize\": 10,\r

    \    \"pageNo\": 0\r

    }"
scripts:
  - type: afterResponse
    code: >-
      pm.test("Response status code is 200", function () {
          pm.expect(pm.response.code).to.equal(200);
      });



      pm.test("Response has the required fields", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.be.an('object');
          pm.expect(responseData).to.have.property('data');
          pm.expect(responseData.data).to.have.property('hasNextPage');
          pm.expect(responseData.data).to.have.property('contents');
          pm.expect(responseData.data).to.have.property('totalPages');
          pm.expect(responseData.data).to.have.property('pageSize');
          pm.expect(responseData.data).to.have.property('currentPage');
          pm.expect(responseData.data).to.have.property('totalElements');
      });



      pm.test("Contents array objects have non-empty required fields", function
      () {
          const responseData = pm.response.json();
          
          pm.expect(responseData.contents).to.be.an('array');
          
          responseData.contents.forEach(function (content) {
              pm.expect(content.name).to.exist.and.to.not.be.empty;
              pm.expect(content.referenceNumber).to.exist.and.to.not.be.empty;
              pm.expect(content.uid).to.exist.and.to.not.be.empty;
              pm.expect(content.memberType).to.exist.and.to.not.be.empty;
              pm.expect(content.membershipNo).to.exist.and.to.not.be.empty;
              pm.expect(content.nid).to.exist.and.to.not.be.empty;
          });
      });



      pm.test("Phone number should be in a valid format", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.have.property('data');
          pm.expect(responseData.data).to.have.property('contents').that.is.an('array').and.not.empty;
          
          responseData.data.contents.forEach(function(member) {
              pm.expect(member).to.have.property('phoneNo').that.is.a('string').and.match(/^\d{10}$/);
          });
      });



      pm.test("Message is an empty string", function () {
        const responseData = pm.response.json();
        
        pm.expect(responseData.message).to.be.an('string').and.to.be.empty;
      });
    language: text/javascript
examples: ./.resources/Member Pageable.resources/examples
order: 1000
