Skip to content

Commit

Permalink
Reproduce issue embroider-build#1038
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Dec 6, 2021
1 parent 1f40072 commit 2121dec
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
19 changes: 19 additions & 0 deletions packages/macros/tests/babel/dependency-satisfies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,24 @@ describe(`dependencySatisfies`, function () {
);
expect(runDefault(code)).toBe(true);
});

test('it considers alpha releases as allowed', () => {
project = new Project('test-app', '1.0.0');
project.addDevDependency('ember-source', '4.2.0-alpha.2');
project.writeSync();

process.chdir(project.baseDir);

let code = transform(
`
import { dependencySatisfies } from '@embroider/macros';
export default function() {
return dependencySatisfies('ember-source', '>= 3.27.0-canary || >= 3.27.0-beta');
}
`,
{ filename: path.join(project.baseDir, 'foo.js') }
);
expect(runDefault(code)).toBe(true);
});
});
});
24 changes: 23 additions & 1 deletion packages/macros/tests/babel/macro-condition.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeRunner, makeBabelConfig, allModes } from './helpers';
import { Project, makeRunner, makeBabelConfig, allModes } from './helpers';
import { allBabelVersions } from '@embroider/test-support';
import { MacrosConfig } from '../../src/node';

Expand Down Expand Up @@ -341,6 +341,28 @@ describe('macroCondition', function () {
expect(code).not.toMatch(/beta/);
});

buildTimeTest('can evaluate pre-release dependency expressions', () => {
let project = new Project('test-app', '1.0.0');
project.addDevDependency('ember-source', '4.2.0-alpha.2');
project.writeSync();

process.chdir(project.baseDir);

let code = transform(`
import { macroCondition, dependencySatisfies } from '@embroider/macros';
export default function() {
return macroCondition(
dependencySatisfies('ember-source', '>=3.27.0-canary || >=3.27.0-beta')
)
? 'success'
: 'failure'
}
`);

expect(run(code)).toBe('success');
expect(code).not.toMatch(/failure/);
});

buildTimeTest('can see booleans inside getConfig', () => {
let code = transform(`
import { macroCondition, getConfig } from '@embroider/macros';
Expand Down

0 comments on commit 2121dec

Please sign in to comment.