|
1 | | -import { useContextFile } from './hooks'; |
| 1 | +import { useContextFile, useSpecfile } from './hooks'; |
2 | 2 | import { ContextFileNotFoundError, KeyNotFoundError, ContextNotFoundError } from './models'; |
3 | 3 | import { ContextTestingHelper } from '../../constants'; |
4 | 4 | import { SpecificationFile } from '../validation'; |
@@ -131,3 +131,30 @@ describe('useContextFile().getContext', () => { |
131 | 131 | expect(response instanceof SpecificationFile).toBeTruthy(); |
132 | 132 | }); |
133 | 133 | }) |
| 134 | + |
| 135 | +describe('useSpecFile should ', () => { |
| 136 | + it('Load spec file from --file flag', () => { |
| 137 | + const { specFile, error } = useSpecfile({ file: './test/specification.yml' }); |
| 138 | + expect(error).toBeUndefined(); |
| 139 | + expect(specFile instanceof SpecificationFile).toBeTruthy(); |
| 140 | + }); |
| 141 | + it('Load spec file from --context flag', () => { |
| 142 | + testingVariables.createDummyContextFile(); |
| 143 | + const { specFile, error } = useSpecfile({ context: 'home' }); |
| 144 | + expect(error).toBeUndefined(); |
| 145 | + expect(specFile instanceof SpecificationFile).toBeTruthy(); |
| 146 | + }); |
| 147 | + it('Load spec file from current context', () => { |
| 148 | + testingVariables.createDummyContextFile(); |
| 149 | + const { specFile, error } = useSpecfile({}); |
| 150 | + expect(error).toBeUndefined(); |
| 151 | + expect(specFile).toBeDefined(); |
| 152 | + }); |
| 153 | + |
| 154 | + it('Throw error when nothing found', () => { |
| 155 | + testingVariables.deleteDummyContextFile() |
| 156 | + testingVariables.deleteDummyContextFile(); |
| 157 | + const { error } = useSpecfile({}); |
| 158 | + expect(error).toBeDefined(); |
| 159 | + }); |
| 160 | +}) |
0 commit comments