Skip to content

Commit

Permalink
normalize tests for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Dec 16, 2024
1 parent b0df18b commit 8da9579
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions tests/scenarios/core-resolver-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ Scenarios.fromProject(() => new Project())
.resolves('@embroider/virtual/components/hello-world')
.toModule();

let templateFile = normalizePath(`${app.dir}/templates/components/hello-world.hbs`);
let componentFile = normalizePath(`${app.dir}/components/hello-world.js`);

pairModule.codeEquals(`
import { setComponentTemplate } from "@ember/component";
import template from "${app.dir}/templates/components/hello-world.hbs";
import template from "${templateFile}";
import { deprecate } from "@ember/debug";
true && !false && deprecate(
"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup 'hello-world'.",
Expand All @@ -258,14 +261,12 @@ Scenarios.fromProject(() => new Project())
},
}
);
import component from "${app.dir}/components/hello-world.js";
import component from "${componentFile}";
export default setComponentTemplate(template, component);
`);

pairModule
.resolves(`${app.dir}/templates/components/hello-world.hbs`)
.to('./templates/components/hello-world.hbs');
pairModule.resolves(`${app.dir}/components/hello-world.js`).to('./components/hello-world.js');
pairModule.resolves(templateFile).to('./templates/components/hello-world.hbs');
pairModule.resolves(componentFile).to('./components/hello-world.js');
});

test('hbs-only component', async function () {
Expand All @@ -281,9 +282,10 @@ Scenarios.fromProject(() => new Project())
.resolves('@embroider/virtual/components/hello-world')
.toModule();

let templateFile = normalizePath(`${app.dir}/templates/components/hello-world.hbs`);
pairModule.codeEquals(`
import { setComponentTemplate } from "@ember/component";
import template from "${app.dir}/templates/components/hello-world.hbs";
import template from "${templateFile}";
import { deprecate } from "@ember/debug";
true && !false && deprecate(
"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup 'hello-world'.",
Expand All @@ -303,9 +305,7 @@ Scenarios.fromProject(() => new Project())
export default setComponentTemplate(template, templateOnlyComponent(undefined, "hello-world"));
`);

pairModule
.resolves(`${app.dir}/templates/components/hello-world.hbs`)
.to('./templates/components/hello-world.hbs');
pairModule.resolves(templateFile).to('./templates/components/hello-world.hbs');
});

test('explicitly namedspaced component', async function () {
Expand Down Expand Up @@ -396,9 +396,11 @@ Scenarios.fromProject(() => new Project())
.resolves('@embroider/virtual/components/hello-world')
.toModule();

let templateFile = normalizePath(`${app.dir}/components/hello-world/template.hbs`);

pairModule.codeEquals(`
import { setComponentTemplate } from "@ember/component";
import template from "${app.dir}/components/hello-world/template.hbs";
import template from "${templateFile}";
import { deprecate } from "@ember/debug";
true && !false && deprecate(
"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup 'template'.",
Expand All @@ -418,9 +420,7 @@ Scenarios.fromProject(() => new Project())
export default setComponentTemplate(template, templateOnlyComponent(undefined, "template"));
`);

pairModule
.resolves(`${app.dir}/components/hello-world/template.hbs`)
.to('./components/hello-world/template.hbs');
pairModule.resolves(templateFile).to('./components/hello-world/template.hbs');
});

test('podded hbs-only component with non-blank podModulePrefix', async function () {
Expand All @@ -436,9 +436,11 @@ Scenarios.fromProject(() => new Project())
.resolves('@embroider/virtual/components/hello-world')
.toModule();

let templateFile = normalizePath(`${app.dir}/pods/components/hello-world/template.hbs`);

pairModule.codeEquals(`
import { setComponentTemplate } from "@ember/component";
import template from "${app.dir}/pods/components/hello-world/template.hbs";
import template from "${templateFile}";
import { deprecate } from "@ember/debug";
true && !false && deprecate(
"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup 'template'.",
Expand All @@ -458,9 +460,7 @@ Scenarios.fromProject(() => new Project())
export default setComponentTemplate(template, templateOnlyComponent(undefined, "template"));
`);

pairModule
.resolves(`${app.dir}/pods/components/hello-world/template.hbs`)
.to('./pods/components/hello-world/template.hbs');
pairModule.resolves(templateFile).to('./pods/components/hello-world/template.hbs');
});

test('podded js-and-hbs component with blank podModulePrefix', async function () {
Expand All @@ -477,9 +477,12 @@ Scenarios.fromProject(() => new Project())
.resolves('@embroider/virtual/components/hello-world')
.toModule();

let templateFile = normalizePath(`${app.dir}/components/hello-world/template.hbs`);
let componentFile = normalizePath(`${app.dir}/components/hello-world/component.js`);

pairModule.codeEquals(`
import { setComponentTemplate } from "@ember/component";
import template from "${app.dir}/components/hello-world/template.hbs";
import template from "${templateFile}";
import { deprecate } from "@ember/debug";
true && !false && deprecate(
"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup 'template'.",
Expand All @@ -495,16 +498,12 @@ Scenarios.fromProject(() => new Project())
},
}
);
import component from "${app.dir}/components/hello-world/component.js";
import component from "${componentFile}";
export default setComponentTemplate(template, component);
`);

pairModule
.resolves(`${app.dir}/components/hello-world/template.hbs`)
.to('./components/hello-world/template.hbs');
pairModule
.resolves(`${app.dir}/components/hello-world/component.js`)
.to('./components/hello-world/component.js');
pairModule.resolves(templateFile).to('./components/hello-world/template.hbs');
pairModule.resolves(componentFile).to('./components/hello-world/component.js');
});

test('podded js-and-hbs component with non-blank podModulePrefix', async function () {
Expand All @@ -521,9 +520,12 @@ Scenarios.fromProject(() => new Project())
.resolves('@embroider/virtual/components/hello-world')
.toModule();

let templateFile = normalizePath(`${app.dir}/pods/components/hello-world/template.hbs`);
let componentFile = normalizePath(`${app.dir}/pods/components/hello-world/component.js`);

pairModule.codeEquals(`
import { setComponentTemplate } from "@ember/component";
import template from "${app.dir}/pods/components/hello-world/template.hbs";
import template from "${templateFile}";
import { deprecate } from "@ember/debug";
true && !false && deprecate(
"Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup 'template'.",
Expand All @@ -539,15 +541,11 @@ Scenarios.fromProject(() => new Project())
},
}
);
import component from "${app.dir}/pods/components/hello-world/component.js";
import component from "${componentFile}";
export default setComponentTemplate(template, component);
`);
pairModule
.resolves(`${app.dir}/pods/components/hello-world/template.hbs`)
.to('./pods/components/hello-world/template.hbs');
pairModule
.resolves(`${app.dir}/pods/components/hello-world/component.js`)
.to('./pods/components/hello-world/component.js');
pairModule.resolves(templateFile).to('./pods/components/hello-world/template.hbs');
pairModule.resolves(componentFile).to('./pods/components/hello-world/component.js');
});

test('plain helper', async function () {
Expand Down Expand Up @@ -1002,3 +1000,11 @@ Scenarios.fromProject(() => new Project())
});
});
});

function normalizePath(s: string): string {
if (process.platform === 'win32') {
return s.replace('/', '\\');
} else {
return s;
}
}

0 comments on commit 8da9579

Please sign in to comment.