-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add getColorByInternalName utility function (#163)
feat: Add getColorByInternalName utility function
- Loading branch information
Showing
4 changed files
with
237 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@doist/todoist-api-typescript", | ||
"version": "2.0.7", | ||
"version": "2.1.0", | ||
"description": "A typescript wrapper for the Todoist REST API.", | ||
"author": "Doist developers", | ||
"repository": "[email protected]:doist/todoist-api-typescript.git", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,50 @@ | ||
import { berryRed, charcoal, taupe, getColorById } from './colors' | ||
import { | ||
berryRed, | ||
taupe, | ||
getColorById, | ||
getColorByName, | ||
getColorByKey, | ||
defaultColor, | ||
} from './colors' | ||
|
||
describe('getColor', () => { | ||
describe('getColorById', () => { | ||
const colorTheories = [ | ||
[0, charcoal], // out of range, defaulted | ||
[0, defaultColor], // out of range, defaulted | ||
[30, berryRed], | ||
[49, taupe], | ||
[999, charcoal], // out of range, defaulted | ||
[999, defaultColor], // out of range, defaulted | ||
] as const | ||
|
||
test.each(colorTheories)('id %p returns color %p', (id, expected) => { | ||
const color = getColorById(id) | ||
expect(color).toEqual(expected) | ||
}) | ||
}) | ||
|
||
describe('getColorByName', () => { | ||
const colorTheories = [ | ||
['Berry Red', berryRed], | ||
['Taupe', taupe], | ||
['berry_red', defaultColor], // does not exist, defaulted | ||
['Some non existing color', defaultColor], // does not exist, defaulted | ||
] as const | ||
|
||
test.each(colorTheories)('name %p returns color %p', (name, expected) => { | ||
const color = getColorByName(name) | ||
expect(color).toEqual(expected) | ||
}) | ||
}) | ||
|
||
describe('getColorByKey', () => { | ||
const colorTheories = [ | ||
['berry_red', berryRed], | ||
['taupe', taupe], | ||
['Berry Red', defaultColor], // does not exist, defaulted | ||
['Some non existing color', defaultColor], // does not exist, defaulted | ||
] as const | ||
|
||
test.each(colorTheories)('key %p returns color %p', (key, expected) => { | ||
const color = getColorByKey(key) | ||
expect(color).toEqual(expected) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters