passbolt-styleguide
Version:
Passbolt styleguide contains common styling assets used by the different sites, plugin, etc.
75 lines (61 loc) • 2.33 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 5.0.0
*/
/**
* Unit tests on OrchestrateResourceForm in regard of specifications
*/
import { defaultProps } from "./AddResourceName.test.data";
import AddResourceNamePage from "./AddResourceName.test.page";
import { defaultAppContext } from "../../../contexts/ExtAppContext.test.data";
beforeEach(() => {
jest.resetModules();
});
describe("AddResourceName", () => {
let page; // The page to test against
const props = defaultProps({
context: defaultAppContext({
getHierarchyFolderCache: () => [{ name: "Folder" }, { name: "subfolder" }],
}),
});
describe("As LU I can see the name field.", () => {
it("As LU I can see the resource password form.", () => {
expect.assertions(2);
page = new AddResourceNamePage(props);
expect(page.exists).toBeTruthy();
expect(page.name.value).toEqual("Passbolt");
});
});
describe("Fill name field", () => {
it("Enter name should call callback function.", async () => {
expect.assertions(3);
let name, value;
jest.spyOn(props, "onChange").mockImplementation((event) => {
name = event.target.name;
value = event.target.value;
});
page = new AddResourceNamePage(props);
await page.fillInput(page.name, "name");
expect(props.onChange).toHaveBeenCalledTimes(1);
expect(name).toEqual("metadata.name");
expect(value).toEqual("name");
});
});
describe("As LU I should see the name disabled.", () => {
it("As LU I can see the name form disabled.", async () => {
expect.assertions(1);
const props = defaultProps({ disabled: true });
page = new AddResourceNamePage(props);
expect(page.name.hasAttribute("disabled")).toBeTruthy();
});
});
});