passbolt-styleguide
Version:
Passbolt styleguide contains common styling assets used by the different sites, plugin, etc.
73 lines (65 loc) • 3.32 kB
JavaScript
/**
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.passbolt.com Passbolt(tm)
* @since 4.12.0
*/
import * as assertEntityProperty from "../../../../../test/assert/assertEntityProperty";
import PassboltResponseEntity from "./PassboltResponseEntity";
import PassboltResponsePaginationHeaderEntity from "./PassboltResponsePaginationHeaderEntity";
import { defaultPassboltResponseDto } from "./PassboltResponseEntity.test.data";
import { defaultPassboltResponseHeaderDto } from "./PassboltResponseHeaderEntity.test.data";
import PassboltResponseHeaderEntity from "./PassboltResponseHeaderEntity";
describe("PassboltResponseEntity", () => {
describe("PassboltResponseEntity::getSchema", () => {
it("validates header property", () => {
assertEntityProperty.integer(PassboltResponsePaginationHeaderEntity, "count");
assertEntityProperty.minimum(PassboltResponsePaginationHeaderEntity, "count", 0);
assertEntityProperty.required(PassboltResponsePaginationHeaderEntity, "count");
});
it("validates body property", () => {
assertEntityProperty.integer(PassboltResponsePaginationHeaderEntity, "limit");
assertEntityProperty.minimum(PassboltResponsePaginationHeaderEntity, "limit", 0);
assertEntityProperty.required(PassboltResponsePaginationHeaderEntity, "limit");
});
it("validates header property", () => {
const dto = defaultPassboltResponseDto();
const successScenarios = [{ scenario: "valid header object", value: defaultPassboltResponseHeaderDto() }];
const failScenarios = [{ scenario: "invalid header type: integer", value: 42 }];
assertEntityProperty.required(PassboltResponseEntity, "header");
assertEntityProperty.assertAssociation(PassboltResponseEntity, "header", dto, successScenarios, failScenarios);
});
});
describe("PassboltResponseEntity:constructor", () => {
it("it should instantiate the entity with a minimal dto", () => {
expect.assertions(1);
const dto = defaultPassboltResponseDto();
const entity = new PassboltResponseEntity(dto);
expect(entity).toBeInstanceOf(PassboltResponseEntity);
});
});
describe("::header", () => {
it("should return the header part of the Passbolt Api Response", () => {
expect.assertions(2);
const dto = defaultPassboltResponseDto();
const entity = new PassboltResponseEntity(dto);
expect(entity.header).toBeInstanceOf(PassboltResponseHeaderEntity);
expect(entity.header.toDto()).toStrictEqual(dto.header);
});
});
describe("::body", () => {
it("should return the body part of the Passbolt Api Response", () => {
expect.assertions(1);
const dto = defaultPassboltResponseDto();
const entity = new PassboltResponseEntity(dto);
expect(entity.body).toStrictEqual(dto.body);
});
});
});