Allow to set tag in description

This commit is contained in:
Manuel Bouza
2019-03-26 16:00:02 +01:00
parent f49c0bdc3d
commit 1b1fae6f7a
3 changed files with 52 additions and 7 deletions

View File

@@ -3,7 +3,8 @@ import {
findProjectByValue,
findProjectByIdentifier,
findTask,
groupedProjectOptions
groupedProjectOptions,
extractAndSetTag
} from "../../src/js/utils"
import { map } from "lodash/fp"
@@ -86,4 +87,36 @@ describe("utils", () => {
])
})
})
describe("extractAndSetTag", () => {
it("sets the correct tag and updates description", () => {
const changeset = {
description: "#meeting Lorem ipsum",
tag: ""
}
expect(extractAndSetTag(changeset)).toEqual({
description: "Lorem ipsum",
tag: "meeting"
})
})
it("only matches tag at the beginning", () => {
const changeset = {
description: "Lorem #meeting ipsum",
tag: ""
}
expect(extractAndSetTag(changeset)).toEqual(changeset)
})
it("returns the changeset if not tag is set", () => {
const changeset = {
description: "Without tag",
tag: ""
}
expect(extractAndSetTag(changeset)).toEqual(changeset)
})
})
})