Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: declare used babel dependencies #24842

Merged
merged 6 commits into from Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hasn't changed in quite a while but it's now getting linted so i added the TODO

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