-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
3,009 additions
and
211 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extension": ["js", "ts"], | ||
"require": ["sucrase/register"], | ||
"spec": ["src/**/*.spec.ts", "test/**/*.spec.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test/snapshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { expect } from 'chai'; | ||
import fs from 'fs'; | ||
import { runCodeGenerator } from '../src/index'; | ||
import { FullAppOptions, Template } from '../src/types'; | ||
|
||
const templates: Template[] = ['axios', 'swr-axios', 'fetch', 'ng1', 'ng2']; | ||
|
||
describe('petstore snapshots', () => { | ||
templates.forEach((template) => { | ||
it(`should match existing ${template} snapshot`, async () => { | ||
const snapshotFile = `./test/snapshots/${template}.ts`; | ||
const parameters: FullAppOptions = { | ||
src: './test/petstore-v2.json', | ||
out: './.tmp/test/', | ||
template, | ||
}; | ||
|
||
const [generatedCode] = await runCodeGenerator(parameters); | ||
|
||
if (process.env.UPDATE_SNAPSHOTS) { | ||
fs.writeFileSync(snapshotFile, generatedCode, 'utf8'); | ||
expect(true).to.eq(true); | ||
} else { | ||
const existingSnapshot = fs.readFileSync(snapshotFile, 'utf8'); | ||
|
||
expect(existingSnapshot).to.equal(generatedCode); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Snapshots | ||
|
||
This directory contains snapshots of all supported templates. This is a very simple | ||
mechanism for detecting (wanted or not) changes in the output of the templates. | ||
|
||
The files are rendered as-is without Prettier formatting. | ||
|
||
Do not make any manual changes in this directory. | ||
|
||
## Updating snapshots | ||
|
||
To update the snapshots, run `UPDATE_SNAPSHOTS=1 yarn test` |
Oops, something went wrong.