Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed May 18, 2023
1 parent d73a6b8 commit 31070b0
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions tests/scenarios/v2-addon-dev-watch-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ Scenarios.fromProject(() => baseV2Addon())
addon.appReexports(['components/**/*.js']),
addon.hbs(),
addon.dependencies(),
addon.keepAssets(['**/*.css']),
addon.publicAssets('custom-public'),
babel({ babelHelpers: 'bundled' }),
addon.clean(),
],
};
`,
'custom-public': {
'demo.css': `button { color: red; }`,
'index.css': `button { color: green; }`,
},
src: {
components: {
'button.hbs': `
Expand All @@ -68,8 +72,7 @@ Scenarios.fromProject(() => baseV2Addon())
</button>
`,
'out.hbs': `<out>{{yield}}</out>`,
'styles.css': `button { color: red; }`,
'index.js': `
'demo.js': `
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
Expand All @@ -85,7 +88,7 @@ Scenarios.fromProject(() => baseV2Addon())
flip = () => (this.active = !this.active);
}
`,
'index.hbs': `Hello there!
'demo.hbs': `Hello there!
<this.Out>{{this.active}}</this.Out>
<this.Button @onClick={{this.flip}} />
Expand Down Expand Up @@ -133,7 +136,7 @@ Scenarios.fromProject(() => baseV2Addon())

await watcher.start();

let someFile = path.join(addon.dir, 'src/components/index.hbs');
let someFile = path.join(addon.dir, 'src/components/demo.hbs');
let manifestPath = path.join(addon.dir, 'package.json');

await isNotModified({
Expand All @@ -146,8 +149,8 @@ Scenarios.fromProject(() => baseV2Addon())
// generally it's bad to introduce time dependencies to a test, but we need to wait long enough
// to guess for how long it'll take for the file system to update our file.
//
// the `stat` is measured in `ms`, so waiting *a lot more*, should be pretty safe.
await aBit(100);
// the `stat` is measured in `ms`, so it's still pretty fast
await aBit(10);
await fs.writeFile(someFile, someContent + `\n`);
},
});
Expand All @@ -165,8 +168,13 @@ Scenarios.fromProject(() => baseV2Addon())
assert,
// Remove a component
fn: async () => {
await fs.rm(path.join(addon.dir, 'src/components/index.js'));
await fs.rm(path.join(addon.dir, 'src/components/index.hbs'));
// generally it's bad to introduce time dependencies to a test, but we need to wait long enough
// to guess for how long it'll take for the file system to update our file.
//
// the `stat` is measured in `ms`, so it's still pretty fast
await aBit(10);
await fs.rm(path.join(addon.dir, 'src/components/demo.js'));
await fs.rm(path.join(addon.dir, 'src/components/demo.hbs'));

await watcher?.settled();
},
Expand All @@ -178,7 +186,7 @@ Scenarios.fromProject(() => baseV2Addon())

await watcher.start();

let someFile = path.join(addon.dir, 'src/components/styles.css');
let someFile = path.join(addon.dir, 'custom-public/demo.css');
let manifestPath = path.join(addon.dir, 'package.json');

await becomesModified({
Expand Down

0 comments on commit 31070b0

Please sign in to comment.