1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as _ from "./resource-properties";
6 import { omit } from "lodash";
8 describe("Resource properties lib", () => {
15 color: ['brown', 'black'],
20 it("should convert a single string value into a list when adding values", () => {
22 _.addProperty(properties, 'animal', 'cat')
24 ...properties, animal: ['dog', 'cat']
28 it("should convert a 2 value list into a string when removing values", () => {
30 _.deleteProperty(properties, 'color', 'brown')
32 ...properties, color: 'black'
36 it("shouldn't add duplicated key:value items", () => {
38 _.addProperty(properties, 'animal', 'dog')
39 ).toEqual(properties);
42 it("should remove the key when deleting from a one value list", () => {
44 _.deleteProperty(properties, 'name', 'Toby')
45 ).toEqual(omit(properties, 'name'));
48 it("should return the same when deleting non-existant value", () => {
50 _.deleteProperty(properties, 'animal', 'dolphin')
51 ).toEqual(properties);
54 it("should return the same when deleting non-existant key", () => {
56 _.deleteProperty(properties, 'doesntexist', 'something')
57 ).toEqual(properties);