Skip to content

Commit 19a0693

Browse files
committed
Add two tests for experimental class/decorators
1 parent 7095e75 commit 19a0693

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

tests/cli-test.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,106 @@ QUnit.module('codemod-cli', function(hooks) {
313313
});
314314
})
315315
);
316+
317+
QUnit.test(
318+
'runs transform against class syntax',
319+
wrap(function*(assert) {
320+
userProject.write({
321+
foo: {
322+
'something.js': `
323+
class Blah {
324+
blah = bar;
325+
}
326+
`,
327+
'other.js': `
328+
class Blah {
329+
blah = bar;
330+
}
331+
`,
332+
'otherthing.ts': `
333+
class Blah {
334+
blah: Map = bar;
335+
}
336+
`,
337+
},
338+
});
339+
340+
yield CodemodCLI.runTransform(codemodProject.path('bin'), 'main', 'foo/*thing.[jt]s');
341+
342+
assert.deepEqual(userProject.read(), {
343+
foo: {
344+
'something.js': `
345+
class halB {
346+
halb = rab;
347+
}
348+
`,
349+
'other.js': `
350+
class Blah {
351+
blah = bar;
352+
}
353+
`,
354+
'otherthing.ts': `
355+
class halB {
356+
halb: paM = rab;
357+
}
358+
`,
359+
},
360+
});
361+
})
362+
);
363+
364+
QUnit.test(
365+
'runs transform against decorator syntax',
366+
wrap(function*(assert) {
367+
userProject.write({
368+
foo: {
369+
'something.js': `
370+
class Blah {
371+
@bar
372+
blah() {}
373+
}
374+
`,
375+
'other.js': `
376+
class Blah {
377+
@bar
378+
blah() {}
379+
}
380+
`,
381+
'otherthing.ts': `
382+
class Blah {
383+
@bar
384+
blah() {}
385+
}
386+
`,
387+
},
388+
});
389+
390+
yield CodemodCLI.runTransform(codemodProject.path('bin'), 'main', 'foo/*thing.[jt]s');
391+
392+
assert.deepEqual(userProject.read(), {
393+
foo: {
394+
'something.js': `
395+
class halB {
396+
@rab
397+
halb() {}
398+
}
399+
`,
400+
'other.js': `
401+
class Blah {
402+
@bar
403+
blah() {}
404+
}
405+
`,
406+
'otherthing.ts': `
407+
class halB {
408+
@rab
409+
halb() {}
410+
}
411+
`,
412+
},
413+
});
414+
})
415+
);
316416
});
317417
});
318418
});

0 commit comments

Comments
 (0)