Skip to content

Commit

Permalink
correct import paths for proxied color.js in karma
Browse files Browse the repository at this point in the history
  • Loading branch information
gaiety-deque committed May 14, 2024
1 parent 0e01497 commit 6bc8763
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 3 additions & 8 deletions test/integration/full/patch/patch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// recommending to `null` out `window.CSS` for JSDOM's benefit
// https://github.com/thymikee/jest-preset-angular/commit/ac30648347ab41e0cbce741f66ae2a06b766fe13#diff-f2981abe444e6cc2b341b0d7cadb3932d2f1fbb6601aebeaf70f8bb387439d35

const karmaBaseURL = '/base';
const originalWindowCSS = window.CSS;

function resetWindowCSSMock() {
Expand All @@ -16,9 +15,7 @@ function mockWindowCSS() {
describe('patch test', function () {
it('when not mocked, imports and works as expected', async function () {
try {
const { default: Color } = await import(
`${karmaBaseURL}/patches/unpatched/color.js`
);
const { default: Color } = await import('/unpatched/color.js');
let color = new Color('slategray');
assert.ok(color);
} catch (error) {
Expand All @@ -42,7 +39,7 @@ describe('patch test', function () {

it('not patched: `CSS.supports` fails to load when `window.CSS === null`', async function () {
try {
`${karmaBaseURL}/patches/unpatched/color.js`;
await import('/unpatched/color.js');
} catch ({ name, message }) {
assert.equal(name, 'TypeError');
assert.equal(
Expand All @@ -54,9 +51,7 @@ describe('patch test', function () {

it('patched: `CSS?.supports` optional chaining does not fail importing when `window.CSS === null`', async function () {
try {
const { default: Color } = await import(
`${karmaBaseURL}/node_modules/colorjs.io/dist/color.js`
);
const { default: Color } = await import('/color.js');
let color = new Color('slategray');
assert.ok(color);
} catch (error) {
Expand Down
6 changes: 4 additions & 2 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ module.exports = function (config) {
frameworks: ['mocha', 'chai', 'sinon'],
files: [
{
pattern: 'node_modules/colorjs.io/dist/*',
pattern: 'node_modules/colorjs.io/dist/color.js',
included: false,
served: true
},
{ pattern: 'patches/unpatched/*{js,cjs}', included: false, served: true },
{ pattern: 'patches/unpatched/*.js', included: false, served: true },
{ pattern: 'test/mock/**/*.html', included: false, served: true },
{ pattern: 'test/integration/**/*.css', included: false, served: true },
{
Expand All @@ -109,6 +109,8 @@ module.exports = function (config) {
'test/testutils.js'
].concat(testPaths),
proxies: {
'/color.js': '/base/node_modules/colorjs.io/dist/color.js',
'/unpatched': '/base/patches/unpatched',
'/test': '/base/test',
'/mock': '/base/test/mock',
'/integration': '/base/test/integration',
Expand Down

0 comments on commit 6bc8763

Please sign in to comment.