Skip to content

Commit

Permalink
fix: declare used babel dependencies (#24842)
Browse files Browse the repository at this point in the history
* fix: declare used babel dependencies

* try this???

* unlock deps
  • Loading branch information
mjhenkes authored and flotwig committed Dec 13, 2022
1 parent 6c17809 commit 3dbe730
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 41 deletions.
48 changes: 41 additions & 7 deletions npm/grep/cypress/e2e/unit.js
Expand Up @@ -14,6 +14,7 @@ describe('utils', () => {
context('parseTitleGrep', () => {
it('grabs the positive title', () => {
const parsed = parseTitleGrep('hello w')

expect(parsed).to.deep.equal({
title: 'hello w',
invert: false,
Expand All @@ -22,6 +23,7 @@ describe('utils', () => {

it('trims the string', () => {
const parsed = parseTitleGrep(' hello w ')

expect(parsed).to.deep.equal({
title: 'hello w',
invert: false,
Expand All @@ -30,6 +32,7 @@ describe('utils', () => {

it('inverts the string', () => {
const parsed = parseTitleGrep('-hello w')

expect(parsed).to.deep.equal({
title: 'hello w',
invert: true,
Expand All @@ -38,6 +41,7 @@ describe('utils', () => {

it('trims the inverted the string', () => {
const parsed = parseTitleGrep(' -hello w ')

expect(parsed).to.deep.equal({
title: 'hello w',
invert: true,
Expand All @@ -46,13 +50,15 @@ describe('utils', () => {

it('returns null for undefined input', () => {
const parsed = parseTitleGrep()

expect(parsed).to.equal(null)
})
})

context('parseFullTitleGrep', () => {
it('returns list of title greps', () => {
const parsed = parseFullTitleGrep('hello; one; -two')

expect(parsed).to.deep.equal([
{ title: 'hello', invert: false },
{ title: 'one', invert: false },
Expand All @@ -65,6 +71,7 @@ describe('utils', () => {
it('parses AND tags', () => {
// run only the tests with all 3 tags
const parsed = parseTagsGrep('@tag1+@tag2+@tag3')

expect(parsed).to.deep.equal([
// single OR part
[
Expand All @@ -78,6 +85,7 @@ describe('utils', () => {

it('handles dashes in the tag', () => {
const parsed = parseTagsGrep('@smoke+@screen-b')

expect(parsed).to.deep.equal([
[
{ tag: '@smoke', invert: false },
Expand All @@ -89,6 +97,7 @@ describe('utils', () => {
it('parses OR tags spaces', () => {
// run tests with tag1 OR tag2 or tag3
const parsed = parseTagsGrep('@tag1 @tag2 @tag3')

expect(parsed).to.deep.equal([
[{ tag: '@tag1', invert: false }],
[{ tag: '@tag2', invert: false }],
Expand All @@ -99,6 +108,7 @@ describe('utils', () => {
it('parses OR tags commas', () => {
// run tests with tag1 OR tag2 or tag3
const parsed = parseTagsGrep('@tag1,@tag2,@tag3')

expect(parsed).to.deep.equal([
[{ tag: '@tag1', invert: false }],
[{ tag: '@tag2', invert: false }],
Expand All @@ -108,11 +118,13 @@ describe('utils', () => {

it('parses inverted tag', () => {
const parsed = parseTagsGrep('-@tag1')

expect(parsed).to.deep.equal([[{ tag: '@tag1', invert: true }]])
})

it('parses tag1 but not tag2 with space', () => {
const parsed = parseTagsGrep('@tag1 -@tag2')

expect(parsed).to.deep.equal([
[{ tag: '@tag1', invert: false }],
[{ tag: '@tag2', invert: true }],
Expand All @@ -121,6 +133,7 @@ describe('utils', () => {

it('forgives extra spaces', () => {
const parsed = parseTagsGrep(' @tag1 -@tag2 ')

expect(parsed).to.deep.equal([
[{ tag: '@tag1', invert: false }],
[{ tag: '@tag2', invert: true }],
Expand All @@ -129,6 +142,7 @@ describe('utils', () => {

it('parses tag1 but not tag2 with comma', () => {
const parsed = parseTagsGrep('@tag1,-@tag2')

expect(parsed).to.deep.equal([
[{ tag: '@tag1', invert: false }],
[{ tag: '@tag2', invert: true }],
Expand All @@ -137,15 +151,17 @@ describe('utils', () => {

it('filters out empty tags', () => {
const parsed = parseTagsGrep(',, @tag1,-@tag2,, ,, ,')

expect(parsed).to.deep.equal([
[{ tag: '@tag1', invert: false }],
[{ tag: '@tag2', invert: true }],
])
})

// would need to change the tokenizer
// TODO: would need to change the tokenizer
it.skip('parses tag1 but not tag2', () => {
const parsed = parseTagsGrep('@tag1-@tag2')

expect(parsed).to.deep.equal([
[
{ tag: '@tag1', invert: false },
Expand All @@ -156,8 +172,9 @@ describe('utils', () => {

it('allows all tags to be inverted', () => {
const parsed = parseTagsGrep('--@tag1,--@tag2')

expect(parsed).to.deep.equal([
[ { tag: '@tag1', invert: true }, { tag: '@tag2', invert: true } ]
[{ tag: '@tag1', invert: true }, { tag: '@tag2', invert: true }],
])
})
})
Expand All @@ -170,6 +187,7 @@ describe('utils', () => {

it('creates just the title grep', () => {
const parsed = parseGrep('hello w')

expect(parsed).to.deep.equal({
title: [
{
Expand All @@ -183,6 +201,7 @@ describe('utils', () => {

it('creates object from the grep string only', () => {
const parsed = parseGrep('hello w')

expect(parsed).to.deep.equal({
title: [
{
Expand Down Expand Up @@ -224,6 +243,7 @@ describe('utils', () => {

it('creates object from the grep string and tags', () => {
const parsed = parseGrep('hello w', '@tag1+@tag2+@tag3')

expect(parsed).to.deep.equal({
title: [
{
Expand Down Expand Up @@ -251,6 +271,7 @@ describe('utils', () => {
expect(
shouldTestRun(parsed, ['@tag1', '@tag2', '@tag3', '@tag4']),
).to.equal(true)

// title matches, but tags do not
expect(shouldTestRun(parsed, 'hello w', ['@tag1', '@tag2'])).to.equal(
false,
Expand All @@ -269,6 +290,7 @@ describe('utils', () => {
// our parsing and decision logic computes the expected result
const shouldIt = (used, tags, expected) => {
const parsedTags = parseTagsGrep(used)

expect(
shouldTestRunTags(parsedTags, tags),
`"${used}" against "${tags}"`,
Expand Down Expand Up @@ -308,36 +330,42 @@ describe('utils', () => {
// and apply the first argument in shouldTestRun
const checkName = (grep, grepTags) => {
const parsed = parseGrep(grep, grepTags)

expect(parsed).to.be.an('object')

return (testName, testTags = []) => {
expect(testName, 'test title').to.be.a('string')
expect(testTags, 'test tags').to.be.an('array')

return shouldTestRun(parsed, testName, testTags)
}
}

it('simple tag', () => {
const parsed = parseGrep('@tag1')

expect(shouldTestRun(parsed, 'no tag1 here')).to.be.false
expect(shouldTestRun(parsed, 'has @tag1 in the name')).to.be.true
})

it('with invert title', () => {
const t = checkName('-hello')

expect(t('no greetings')).to.be.true
expect(t('has hello world')).to.be.false
})

it('with invert option', () => {
const t = checkName(null, '-@tag1')

expect(t('no tags here')).to.be.true
expect(t('has tag1', ['@tag1'])).to.be.false
expect(t('has other tags', ['@tag2'])).to.be.true
})

it('with AND option', () => {
const t = checkName('', '@tag1+@tag2')

expect(t('no tag1 here')).to.be.false
expect(t('has only @tag1', ['@tag1'])).to.be.false
expect(t('has only @tag2', ['@tag2'])).to.be.false
Expand All @@ -346,20 +374,23 @@ describe('utils', () => {

it('with OR option', () => {
const t = checkName(null, '@tag1 @tag2')

expect(t('no tag1 here')).to.be.false
expect(t('has only @tag1 in the name', ['@tag1'])).to.be.true
expect(t('has only @tag2 in the name', ['@tag2'])).to.be.true
expect(t('has @tag1 and @tag2 in the name', ['@tag1', '@tag2'])).to.be
.true
.true
})

it('OR with AND option', () => {
const t = checkName(null, '@tag1 @tag2+@tag3')

expect(t('no tag1 here')).to.be.false
expect(t('has only @tag1 in the name', ['@tag1'])).to.be.true
expect(t('has only @tag2 in the name', ['@tag2'])).to.be.false
expect(t('has only @tag2 in the name and also @tag3', ['@tag2', '@tag3']))
.to.be.true
.to.be.true

expect(
t('has @tag1 and @tag2 and @tag3 in the name', [
'@tag1',
Expand All @@ -371,8 +402,9 @@ describe('utils', () => {

it('Multiple invert strings and a simple one', () => {
const t = checkName('-name;-hey;number')

expect(t('number should only be matches without a n-a-m-e')).to.be.true
expect(t("number can't be name")).to.be.false
expect(t('number can\'t be name')).to.be.false
expect(t('The man needs a name')).to.be.false
expect(t('number hey name')).to.be.false
expect(t('numbers hey name')).to.be.false
Expand All @@ -382,15 +414,17 @@ describe('utils', () => {

it('Only inverted strings', () => {
const t = checkName('-name;-hey')
expect(t("I'm matched")).to.be.true
expect(t("hey! I'm not")).to.be.false

expect(t('I\'m matched')).to.be.true
expect(t('hey! I\'m not')).to.be.false
expect(t('My name is weird')).to.be.false
})
})

context('parseFullTitleGrep', () => {
const shouldIt = (search, testName, expected) => {
const parsed = parseFullTitleGrep(search)

expect(
shouldTestRunTitle(parsed, testName),
`"${search}" against title "${testName}"`,
Expand Down
6 changes: 4 additions & 2 deletions npm/webpack-preprocessor/package.json
Expand Up @@ -21,7 +21,10 @@
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, ."
},
"dependencies": {
"@babel/parser": "7.13.0",
"@babel/core": "^7.0.1",
"@babel/generator": "^7.17.9",
"@babel/parser": "^7.13.0",
"@babel/traverse": "^7.17.9",
"bluebird": "3.7.1",
"debug": "^4.3.2",
"fs-extra": "^10.1.0",
Expand All @@ -32,7 +35,6 @@
"webpack-virtual-modules": "^0.4.4"
},
"devDependencies": {
"@babel/core": "^7.0.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.8.3",
"@babel/preset-env": "^7.0.0",
"@fellow/eslint-plugin-coffee": "0.4.13",
Expand Down

0 comments on commit 3dbe730

Please sign in to comment.