-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/NotePlan/plugins
- Loading branch information
Showing
103 changed files
with
22,764 additions
and
885 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
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
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
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import * as tt from '../src/tagTasks' | ||
|
||
/* | ||
describe(section('copyTagsFromLineAbove'), () => { | ||
it(`should render default date object`, () => {}) | ||
}) | ||
*/ | ||
|
||
// Jest codedungeon bersion | ||
import colors from 'chalk' | ||
const PLUGIN_NAME = `${colors.yellow('dwertheimer.TaskAutomations')}` | ||
const section = colors.blue | ||
describe(`${PLUGIN_NAME}`, () => { | ||
describe(section('getTagsFromString'), () => { | ||
it(`should not find anything if no tags`, () => { | ||
const text = `word something nothing` | ||
const tags = tt.getTagsFromString(text) | ||
expect(tags).toEqual({ hashtags: [], mentions: [] }) | ||
}) | ||
it(`should find tags/mentions and return them in an object`, () => { | ||
const text = `text1 #tag1 #tag2 text2 @mention1 @mention2 text3` | ||
const tags = tt.getTagsFromString(text) | ||
expect(tags).toEqual({ | ||
hashtags: ['#tag1', '#tag2'], | ||
mentions: ['@mention1', '@mention2'], | ||
}) | ||
}) | ||
}) | ||
describe(section('getUnduplicatedMergedTagArray'), () => { | ||
it(`should return nothing if there are no tags`, () => { | ||
const existingTags = [] | ||
const newTags = [] | ||
const tags = tt.getUnduplicatedMergedTagArray(existingTags, newTags) | ||
expect(tags).toEqual(newTags) | ||
}) | ||
it(`should return newTags if there are no oldTags`, () => { | ||
const existingTags = [] | ||
const newTags = ['@foo'] | ||
const tags = tt.getUnduplicatedMergedTagArray(existingTags, newTags) | ||
expect(tags).toEqual(newTags) | ||
}) | ||
it(`should return oldTags if there are no newTags`, () => { | ||
const existingTags = ['@foo'] | ||
const newTags = [] | ||
const tags = tt.getUnduplicatedMergedTagArray(existingTags, newTags) | ||
expect(tags).toEqual(existingTags) | ||
}) | ||
it(`should return merged if both have tags`, () => { | ||
const existingTags = ['#tag1', '#tag2'] | ||
const newTags = ['#tag3', '#tag4'] | ||
const tags = tt.getUnduplicatedMergedTagArray(existingTags, newTags) | ||
expect(tags).toEqual([...existingTags, ...newTags]) | ||
}) | ||
}) | ||
describe(section('removeTagsFromLine'), () => { | ||
const text = `text1 #tag1 #tag2 text2 @mention1 @mention2 text3` | ||
const toRemove = ['#tag1', '@mention2'] | ||
it(`should remove tags from text`, () => { | ||
const revisedText = tt.removeTagsFromLine(text, toRemove) | ||
expect(revisedText).toEqual(`text1 #tag2 text2 @mention1 text3`) | ||
}) | ||
it(`should do nothing if no tags to remove`, () => { | ||
const revisedText = tt.removeTagsFromLine(text, []) | ||
expect(revisedText).toEqual(text) | ||
}) | ||
}) | ||
|
||
describe(section('appendTagsToText'), () => { | ||
it(`should reorder tags mentions first then hashtags`, () => { | ||
const text = `test #bar @foo #yo` | ||
const newTags = { hashtags: [], mentions: [] } | ||
const ret = tt.appendTagsToText(text, newTags) | ||
expect(ret).toEqual(`test #bar #yo @foo`) | ||
}) | ||
it(`should add a tag if one is new`, () => { | ||
const text = `word something nothing #bar #faz @foo` | ||
const newTags = { hashtags: ['#far'], mentions: [] } | ||
const ret = tt.appendTagsToText(text, newTags) | ||
expect(ret).toEqual(`word something nothing #bar #faz #far @foo`) | ||
}) | ||
}) | ||
}) |
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
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
Oops, something went wrong.