Skip to content

Commit

Permalink
test: update tests with new swc flag
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Aug 13, 2024
1 parent 6ee1f20 commit a902f79
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 142 deletions.
24 changes: 12 additions & 12 deletions test/snapshots/transform.test.js.snapshot
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
exports[`should perform transformation with error 1`] = `
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\nx = 7;\\nthrow new Error(\\"foo\\");\\n"
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\noutput = 7;\\nthrow new Error(\\"foo\\");\\n"
`;

exports[`should perform transformation with error 2`] = `
"{\\"version\\":3,\\"sources\\":[\\"foo.ts\\"],\\"names\\":[],\\"mappings\\":\\";UACS;;;GAAA,QAAA;AAKL;AACA,MAAM,IAAI,MAAM\\"}"
"{\\"version\\":3,\\"sources\\":[\\"foo.ts\\"],\\"names\\":[],\\"mappings\\":\\";UACS;;;GAAA,QAAA;AAIL;AACA,MAAM,IAAI,MAAM\\"}"
`;

exports[`should perform transformation with source maps 1`] = `
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\nx = 7;\\n"
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\noutput = 7;\\n"
`;

exports[`should perform transformation with source maps 2`] = `
"{\\"version\\":3,\\"sources\\":[\\"foo.ts\\"],\\"names\\":[],\\"mappings\\":\\";UACS;;;GAAA,QAAA;AAKL\\"}"
`;

exports[`should perform transformation with source maps no filename 1`] = `
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\nx = 7;\\n"
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\noutput = 7;\\n"
`;

exports[`should perform transformation with source maps no filename 2`] = `
"{\\"version\\":3,\\"sources\\":[\\"<anon>\\"],\\"sourcesContent\\":[\\"\\\\n enum Foo {\\\\n Bar = 7,\\\\n Baz = 2,\\\\n }\\\\n\\\\n x = Foo.Bar\\"],\\"names\\":[],\\"mappings\\":\\";UACS;;;GAAA,QAAA;AAKL\\"}"
"{\\"version\\":3,\\"sources\\":[\\"<anon>\\"],\\"sourcesContent\\":[\\"\\\\n enum Foo {\\\\n Bar = 7,\\\\n Baz = 2,\\\\n }\\\\n output = Foo.Bar\\"],\\"names\\":[],\\"mappings\\":\\";UACS;;;GAAA,QAAA;AAIL\\"}"
`;

exports[`should perform transformation without source maps 1`] = `
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\nx = 7;\\n"
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\noutput = 7;\\n"
`;

exports[`should perform transformation without source maps and filename 1`] = `
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\nx = 7;\\n"
"var Foo;\\n(function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n})(Foo || (Foo = {}));\\noutput = 7;\\n"
`;

exports[`should transform TypeScript class decorators with multiple decorators 1`] = `
"@sealed\\n@log\\nclass BugReport {\\n type = \\"report\\";\\n title;\\n constructor(t){\\n this.title = t;\\n }\\n}\\nfunction sealed(constructor) {\\n Object.seal(constructor);\\n Object.seal(constructor.prototype);\\n}\\nfunction log(constructor) {\\n console.log(\\"Creating instance of\\", constructor.name);\\n}\\nconst report = new BugReport(\\"Test\\");\\n"
"@sealed\\n@log\\nclass BugReport {\\n type = \\"report\\";\\n title;\\n constructor(t){\\n this.title = t;\\n }\\n}\\nfunction sealed(constructor) {\\n Object.seal(constructor);\\n Object.seal(constructor.prototype);\\n}\\nfunction log(constructor) {\\n console.log(\\"Creating instance of\\", constructor.name);\\n}\\noutput = new BugReport(\\"Test\\");\\n"
`;

exports[`should transform TypeScript class fields 1`] = `
"class Counter {\\n count = 0;\\n increment() {\\n this.count++;\\n }\\n}\\n"
"class Counter {\\n count = 0;\\n increment() {\\n this.count++;\\n }\\n}\\nconst counter = new Counter();\\ncounter.increment();\\noutput = counter.count;\\n"
`;

exports[`should transform TypeScript namespaces with additional functionality 1`] = `
"var Validation;\\n(function(Validation) {\\n const lettersRegexp = /^[A-Za-z]+$/;\\n class LettersOnlyValidator {\\n isAcceptable(s) {\\n return lettersRegexp.test(s);\\n }\\n static createValidator() {\\n return new LettersOnlyValidator();\\n }\\n }\\n Validation.LettersOnlyValidator = LettersOnlyValidator;\\n})(Validation || (Validation = {}));\\nconst validator = Validation.LettersOnlyValidator.createValidator();\\nconst isValid = validator.isAcceptable(\\"test\\");\\n// Exporting these for VM context\\nglobalThis.validator = validator;\\nglobalThis.isValid = isValid;\\n"
"var Validation;\\n(function(Validation) {\\n const lettersRegexp = /^[A-Za-z]+$/;\\n class LettersOnlyValidator {\\n isAcceptable(s) {\\n return lettersRegexp.test(s);\\n }\\n static createValidator() {\\n return new LettersOnlyValidator();\\n }\\n }\\n Validation.LettersOnlyValidator = LettersOnlyValidator;\\n})(Validation || (Validation = {}));\\nconst validator = Validation.LettersOnlyValidator.createValidator();\\nconst isValid = validator.isAcceptable(\\"test\\");\\noutput = {\\n validator,\\n isValid\\n};\\n"
`;

exports[`should transform TypeScript private class fields 1`] = `
"class Counter {\\n #count = 0;\\n increment() {\\n this.#count++;\\n }\\n getCount() {\\n return this.#count;\\n }\\n}\\n"
"class Counter {\\n #count = 0;\\n increment() {\\n this.#count++;\\n }\\n getCount() {\\n return this.#count;\\n }\\n}\\nconst counter = new Counter();\\ncounter.increment();\\noutput = counter.getCount();\\n"
`;

exports[`should transform TypeScript type annotations and type guards 1`] = `
"function isString(value) {\\n return typeof value === 'string';\\n}\\n"
"function isString(value) {\\n return typeof value === 'string';\\n}\\nconst check = isString(\\"hello\\");\\noutput = check;\\n"
`;
Loading

0 comments on commit a902f79

Please sign in to comment.